Skip to content

Add preact query devtools#10119

Open
JoviDeCroock wants to merge 1 commit intoTanStack:mainfrom
JoviDeCroock:add-preact-devtools-package
Open

Add preact query devtools#10119
JoviDeCroock wants to merge 1 commit intoTanStack:mainfrom
JoviDeCroock:add-preact-devtools-package

Conversation

@JoviDeCroock
Copy link

@JoviDeCroock JoviDeCroock commented Feb 12, 2026

🎯 Changes

This adds the preact-query devtools package similar to the existing vue/solid/svelte/react ones

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

This is the initial release of the package.

Summary by CodeRabbit

  • New Features

    • Introduced Preact Query Devtools package with configurable devtools components for development builds.
    • Added support for floating mode, customizable positioning, and theme configuration.
  • Documentation

    • Added comprehensive devtools documentation covering installation, usage, and configuration options.

@changeset-bot
Copy link

changeset-bot bot commented Feb 12, 2026

⚠️ No Changeset found

Latest commit: fd22045

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Feb 12, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 12, 2026

📝 Walkthrough

Walkthrough

This PR introduces a new @tanstack/preact-query-devtools package, adding Preact-specific wrapper components for TanStack Query Devtools alongside complete package setup, build configuration, documentation, and test infrastructure.

Changes

Cohort / File(s) Summary
Documentation
docs/config.json, docs/framework/preact/devtools.md
Added Devtools entry to Getting Started config and comprehensive documentation covering browser devtools extensions, installation, floating mode usage, and configuration options.
Package Setup
packages/preact-query-devtools/package.json, packages/preact-query-devtools/.attw.json
Established npm package manifest with build/test scripts, dual modern/legacy ESM/CJS outputs, complex export maps, and dependencies on preact-related tooling.
TypeScript Configuration
packages/preact-query-devtools/tsconfig.json, packages/preact-query-devtools/tsconfig.legacy.json, packages/preact-query-devtools/tsconfig.prod.json
Created base and variant TypeScript configurations extending root tsconfig with target-specific compiler options (JSX source, output directories, project references).
Build Configuration
packages/preact-query-devtools/root.tsup.config.js, packages/preact-query-devtools/tsup.config.ts
Introduced dual build target configurations (modern and legacy) with esbuild plugins for ES module path handling and sourcemap generation.
Linting Configuration
packages/preact-query-devtools/eslint.config.js, packages/preact-query-devtools/root.eslint.config.js
Added package-specific and root ESLint configurations extending TanStack base config with TypeScript overrides, cspell integration, and vitest test rules.
Vite Configuration
packages/preact-query-devtools/vite.config.ts
Configured Vite with Preact preset, custom resolve conditions, jsdom testing environment, and coverage settings.
Source Implementation
packages/preact-query-devtools/src/PreactQueryDevtools.tsx, packages/preact-query-devtools/src/PreactQueryDevtoolsPanel.tsx, packages/preact-query-devtools/src/index.ts, packages/preact-query-devtools/src/production.ts
Implemented Preact wrapper components managing devtools lifecycle, reactive prop synchronization via effects, and production-safe tree-shaking with environment guards.
Test Setup
packages/preact-query-devtools/test-setup.ts
Added test infrastructure with DOM cleanup hooks and notify manager wrapping for Preact update tracking.

Sequence Diagram(s)

sequenceDiagram
    participant Component as Preact Component
    participant PreactQueryDevtools as PreactQueryDevtools
    participant TanstackQueryDevtools as TanstackQueryDevtools Instance
    participant QueryClient as QueryClient
    participant DOM as DOM

    Component->>PreactQueryDevtools: Mount with props
    PreactQueryDevtools->>QueryClient: useQueryClient(props.client)
    QueryClient-->>PreactQueryDevtools: Return or resolve client
    PreactQueryDevtools->>TanstackQueryDevtools: Create instance
    activate TanstackQueryDevtools
    TanstackQueryDevtools->>TanstackQueryDevtools: Initialize state
    TanstackQueryDevtools-->>PreactQueryDevtools: Instance ready
    PreactQueryDevtools->>DOM: Create div container
    TanstackQueryDevtools->>DOM: Mount into ref
    Note over DOM: Devtools rendered in floating mode

    Component->>PreactQueryDevtools: Update props (buttonPosition, theme, etc.)
    PreactQueryDevtools->>TanstackQueryDevtools: Sync prop changes via effects
    TanstackQueryDevtools->>TanstackQueryDevtools: Update configuration state
    TanstackQueryDevtools->>DOM: Re-render with new state

    Component->>PreactQueryDevtools: Unmount
    TanstackQueryDevtools->>DOM: Unmount from ref
    deactivate TanstackQueryDevtools
    PreactQueryDevtools->>DOM: Remove container
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

package: query-devtools, preact

Suggested reviewers

  • TkDodo
  • AlemTuzlak

Poem

🐰 A bundle of joy, a devtools delight,
Preact's whiskers now glow in dev-mode light,
Config and code hop from branch to the main,
Lifecycle effects keep the state sane,
Tree-shaking production? We leave no trace! 🌳✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add preact query devtools' clearly summarizes the main change: introducing a new preact-query devtools package.
Description check ✅ Passed The description follows the template structure with completed sections: Changes explain the addition of the preact-query devtools package, Checklist items are marked complete, and Release Impact notes this is an initial package release.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@JoviDeCroock JoviDeCroock force-pushed the add-preact-devtools-package branch from 359aade to 1e3d386 Compare February 12, 2026 06:06
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@packages/preact-query-devtools/src/PreactQueryDevtools.tsx`:
- Line 1: The import members are not alphabetically ordered; update the named
import from 'preact/hooks' so the specifiers are sorted alphabetically (e.g.,
ensure useEffect comes before useRef and useState) in the statement that
currently imports useRef, useState, useEffect to satisfy ESLint for the
PreactQueryDevtools component.
- Around line 33-38: The JSDoc for the prop errorTypes is wrong (copied from
styleNonce); update the comment above the errorTypes property (type
Array<DevtoolsErrorType>) to describe what errorTypes does — e.g., that it
accepts an array of DevtoolsErrorType values to filter or categorize which error
kinds the devtools should display or highlight (mention valid enum/members if
applicable), and clarify default behavior when the array is empty or omitted;
edit the JSDoc near the errorTypes declaration to reflect this intent.

In `@packages/preact-query-devtools/vite.config.ts`:
- Around line 1-4: The import order violates ESLint: move the packageJson import
before the type import from 'vite' so that "import packageJson from
'./package.json'" appears above "import type { UserConfig as ViteUserConfig }
from 'vite'"; update the top of the file to list imports as preact, packageJson,
then the vite type import (keeping existing symbols preact, defineConfig,
ViteUserConfig, and packageJson intact).
🧹 Nitpick comments (1)
packages/preact-query-devtools/root.eslint.config.js (1)

20-40: Cspell word list contains terms irrelevant to the Preact package.

Words like solidjs, vue-demi, ɵkind, and ɵproviders appear to be copy-pasted from another package's config. They're harmless but add noise — consider trimming to only Preact-relevant terms.

@@ -0,0 +1,131 @@
import { useRef, useState, useEffect } from 'preact/hooks'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Sort import members alphabetically to satisfy ESLint.

ESLint reports that useEffect should come before useRef in the import declaration.

Proposed fix
-import { useRef, useState, useEffect } from 'preact/hooks'
+import { useEffect, useRef, useState } from 'preact/hooks'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { useRef, useState, useEffect } from 'preact/hooks'
import { useEffect, useRef, useState } from 'preact/hooks'
🧰 Tools
🪛 ESLint

[error] 1-1: Member 'useEffect' of the import declaration should be sorted alphabetically.

(sort-imports)

🤖 Prompt for AI Agents
In `@packages/preact-query-devtools/src/PreactQueryDevtools.tsx` at line 1, The
import members are not alphabetically ordered; update the named import from
'preact/hooks' so the specifiers are sorted alphabetically (e.g., ensure
useEffect comes before useRef and useState) in the statement that currently
imports useRef, useState, useEffect to satisfy ESLint for the
PreactQueryDevtools component.

Comment on lines 33 to 38
/**
* Use this to pass a nonce to the style tag that is added to the document
* head. This is useful if you are using a Content Security Policy (CSP)
* nonce to allow inline styles.
*/
errorTypes?: Array<DevtoolsErrorType>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Copy-paste error in JSDoc for errorTypes.

The docstring for errorTypes is identical to the one for styleNonce ("Use this to pass a nonce to the style tag…"). It should describe the error types functionality instead.

Proposed fix
   /**
-   * Use this to pass a nonce to the style tag that is added to the document
-   * head. This is useful if you are using a Content Security Policy (CSP)
-   * nonce to allow inline styles.
+   * Use this to provide custom error type handlers for the devtools panel.
    */
   errorTypes?: Array<DevtoolsErrorType>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/**
* Use this to pass a nonce to the style tag that is added to the document
* head. This is useful if you are using a Content Security Policy (CSP)
* nonce to allow inline styles.
*/
errorTypes?: Array<DevtoolsErrorType>
/**
* Use this to provide custom error type handlers for the devtools panel.
*/
errorTypes?: Array<DevtoolsErrorType>
🤖 Prompt for AI Agents
In `@packages/preact-query-devtools/src/PreactQueryDevtools.tsx` around lines 33 -
38, The JSDoc for the prop errorTypes is wrong (copied from styleNonce); update
the comment above the errorTypes property (type Array<DevtoolsErrorType>) to
describe what errorTypes does — e.g., that it accepts an array of
DevtoolsErrorType values to filter or categorize which error kinds the devtools
should display or highlight (mention valid enum/members if applicable), and
clarify default behavior when the array is empty or omitted; edit the JSDoc near
the errorTypes declaration to reflect this intent.

Comment on lines +1 to +4
import preact from '@preact/preset-vite'
import { defineConfig } from 'vitest/config'
import type { UserConfig as ViteUserConfig } from 'vite'
import packageJson from './package.json'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix import order to satisfy ESLint.

ESLint flags that the ./package.json import should occur before the type import of vite. This is reported as an error and may fail CI.

🔧 Proposed fix
 import preact from '@preact/preset-vite'
 import { defineConfig } from 'vitest/config'
-import type { UserConfig as ViteUserConfig } from 'vite'
 import packageJson from './package.json'
+import type { UserConfig as ViteUserConfig } from 'vite'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import preact from '@preact/preset-vite'
import { defineConfig } from 'vitest/config'
import type { UserConfig as ViteUserConfig } from 'vite'
import packageJson from './package.json'
import preact from '@preact/preset-vite'
import { defineConfig } from 'vitest/config'
import packageJson from './package.json'
import type { UserConfig as ViteUserConfig } from 'vite'
🧰 Tools
🪛 ESLint

[error] 4-4: ./package.json import should occur before type import of vite

(import/order)

🤖 Prompt for AI Agents
In `@packages/preact-query-devtools/vite.config.ts` around lines 1 - 4, The import
order violates ESLint: move the packageJson import before the type import from
'vite' so that "import packageJson from './package.json'" appears above "import
type { UserConfig as ViteUserConfig } from 'vite'"; update the top of the file
to list imports as preact, packageJson, then the vite type import (keeping
existing symbols preact, defineConfig, ViteUserConfig, and packageJson intact).

@JoviDeCroock JoviDeCroock force-pushed the add-preact-devtools-package branch from 1e3d386 to d631591 Compare February 12, 2026 06:13
@JoviDeCroock JoviDeCroock force-pushed the add-preact-devtools-package branch from d631591 to fd22045 Compare February 12, 2026 06:14
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@docs/framework/preact/devtools.md`:
- Around line 69-87: The Options docs omit the hideDisabledQueries and theme
props present on the DevtoolsOptions interface in PreactQueryDevtools.tsx;
update this Options section to document both: add a `hideDisabledQueries?:
boolean` entry describing that it hides queries in the UI that are disabled, and
add a `theme?: "light" | "dark" | string` (or whatever variants the
implementation accepts) entry describing theme selection and default. Reference
the DevtoolsOptions interface/props in PreactQueryDevtools.tsx to ensure wording
and default values match the implementation.

In `@packages/preact-query-devtools/src/PreactQueryDevtoolsPanel.tsx`:
- Line 1: The import list in PreactQueryDevtoolsPanel (the import from
'preact/hooks') is not alphabetized; reorder the imported members so they are
alphabetical (useEffect, useRef, useState) in the import declaration to satisfy
ESLint (update the import that currently declares useRef, useState, useEffect).
🧹 Nitpick comments (1)
packages/preact-query-devtools/src/index.ts (1)

18-18: Export DevtoolsOptions type alongside DevtoolsPanelOptions.

DevtoolsPanelOptions is re-exported from the index, but DevtoolsOptions (defined in PreactQueryDevtools.tsx) is not. Consumers typing props for PreactQueryDevtools must import from the component file directly instead of the main entry point, creating an asymmetric and less discoverable API.

Suggested fix
 export type DevtoolsPanelOptions = DevtoolsPanel.DevtoolsPanelOptions
+export type DevtoolsOptions = Devtools.DevtoolsOptions

Comment on lines +69 to +87
### Options

- `initialIsOpen: boolean`
- Set this `true` if you want the dev tools to default to being open
- `buttonPosition?: "top-left" | "top-right" | "bottom-left" | "bottom-right"`
- Defaults to `bottom-right`
- The position of the Preact Query logo to open and close the devtools panel
- `position?: "top" | "bottom" | "left" | "right"`
- Defaults to `bottom`
- The position of the Preact Query devtools panel
- `client?: QueryClient`,
- Use this to use a custom QueryClient. Otherwise, the one from the nearest context will be used.
- `errorTypes?: { name: string; initializer: (query: Query) => TError}`
- Use this to predefine some errors that can be triggered on your queries. Initializer will be called (with the specific query) when that error is toggled on from the UI. It must return an Error.
- `styleNonce?: string`
- Use this to pass a nonce to the style tag that is added to the document head. This is useful if you are using a Content Security Policy (CSP) nonce to allow inline styles.
- `shadowDOMTarget?: ShadowRoot`
- Default behavior will apply the devtool's styles to the head tag within the DOM.
- Use this to pass a shadow DOM target to the devtools so that the styles will be applied within the shadow DOM instead of within the head tag in the light DOM.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Documentation is missing hideDisabledQueries and theme options.

The DevtoolsOptions interface in PreactQueryDevtools.tsx includes hideDisabledQueries and theme props, but this Options section doesn't list them. Consider adding them for completeness.

🤖 Prompt for AI Agents
In `@docs/framework/preact/devtools.md` around lines 69 - 87, The Options docs
omit the hideDisabledQueries and theme props present on the DevtoolsOptions
interface in PreactQueryDevtools.tsx; update this Options section to document
both: add a `hideDisabledQueries?: boolean` entry describing that it hides
queries in the UI that are disabled, and add a `theme?: "light" | "dark" |
string` (or whatever variants the implementation accepts) entry describing theme
selection and default. Reference the DevtoolsOptions interface/props in
PreactQueryDevtools.tsx to ensure wording and default values match the
implementation.

@@ -0,0 +1,110 @@
import { useRef, useState, useEffect } from 'preact/hooks'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Sort import members alphabetically to satisfy ESLint.

ESLint reports that useEffect should come before useRef in the import declaration.

Proposed fix
-import { useRef, useState, useEffect } from 'preact/hooks'
+import { useEffect, useRef, useState } from 'preact/hooks'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { useRef, useState, useEffect } from 'preact/hooks'
import { useEffect, useRef, useState } from 'preact/hooks'
🧰 Tools
🪛 ESLint

[error] 1-1: Member 'useEffect' of the import declaration should be sorted alphabetically.

(sort-imports)

🤖 Prompt for AI Agents
In `@packages/preact-query-devtools/src/PreactQueryDevtoolsPanel.tsx` at line 1,
The import list in PreactQueryDevtoolsPanel (the import from 'preact/hooks') is
not alphabetized; reorder the imported members so they are alphabetical
(useEffect, useRef, useState) in the import declaration to satisfy ESLint
(update the import that currently declares useRef, useState, useEffect).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant