Devtools framework adapters

From TanStack/devtools · View interactive version

Devtools framework adapters is an AI agent skill from the GitHub repository TanStack/devtools. Use devtools-utils factory functions to create per-framework plugin adapters. createReactPlugin/createSolidPlugin/createVuePlugin/createPreactPlugin, createReactPanel/createSolidPanel/createVuePanel/createPreactPanel. [Plugin, NoOpPlugin] tuple for tree-shaking. DevtoolsPanelProps (theme). Vue uses

How to use this skill

Skill file

Use @tanstack/devtools-utils factory functions to create per-framework devtools plugin adapters. Each framework has a subpath export (/react, /vue, /solid, /preact) with two factories:

  1. createXPlugin -- wraps a component into a [Plugin, NoOpPlugin] tuple for tree-shaking.
  2. createXPanel -- wraps a class-based devtools core (mount/unmount) into a [Panel, NoOpPanel] component tuple.

Key Source Files

Shared Pattern

All four frameworks follow the same two-factory pattern:

Plugin Factory

Every createXPlugin returns readonly [Plugin, NoOpPlugin]:

Panel Factory

Every createXPanel returns readonly [Panel, NoOpPanel]:

DevtoolsPanelProps

// React, Solid, Preact
interface DevtoolsPanelProps {
  theme?: 'light' | 'dark'
}

// Vue (note: includes 'system')
interface DevtoolsPanelProps {
  theme?: 'dark' | 'light' | 'system'
}

Import from the framework subpath:

import type { DevtoolsPanelProps } from '@tanstack/devtools-utils/react'
import type { DevtoolsPanelProps } from '@tanstack/devtools-utils/vue'
import type { DevtoolsPanelProps } from '@tanstack/devtools-utils/solid'
import type { DevtoolsPanelProps } from '@tanstack/devtools-utils/preact'

Primary Example (React)

import { createReactPlugin } from '@tanstack/devtools-utils/react'

function MyStorePanel({ theme }: { theme?: 'light' | 'dark' }) {
  return <div className={theme}>My Store Devtools</div>
}

const [MyPlugin, NoOpPlugin] = createReactPlugin({
  name: 'My Store',
  id: 'my-store',
  defaultOpen: false,
  Component: MyStorePanel,
})

// Tree-shaking: use NoOp in production
const ActivePlugin =
  process.env.NODE_ENV === 'development' ? MyPlugin : NoOpPlugin

With Class-Based Panel

import {
  createReactPanel,
  createReactPlugin,
} from '@tanstack/devtools-utils/react'

class MyDevtoolsCore {
  mount(el: HTMLElement, theme: 'light' | 'dark') {
    /* render into el */
  }
  unmount() {
    /* cleanup */
  }
}

const [MyPanel, NoOpPanel] = createReactPanel(MyDevtoolsCore)

const [MyPlugin, NoOpPlugin] = createReactPlugin({
  name: 'My Store',
  Component: MyPanel,
})

Framework API Differences

React & Preact -- Options Object

createReactPlugin({ name, id?, defaultOpen?, Component })  // => [Plugin, NoOpPlugin]
createPreactPlugin({ name, id?, defaultOpen?, Component }) // => [Plugin, NoOpPlugin]

Vue -- Positional Arguments, NOT Options Object

createVuePlugin(name: string, component: DefineComponent) // => [Plugin, NoOpPlugin]

Solid -- Same API as React, Different Internals

createSolidPlugin({ name, id?, defaultOpen?, Component }) // => [Plugin, NoOpPlugin]

Common Mistakes

CRITICAL: Using React JSX Pattern in Vue Adapter

Vue uses positional (name, component) arguments, NOT an options object.

// WRONG -- will fail at compile time or produce garbage at runtime
const [MyPlugin, NoOpPlugin] = createVuePlugin({
  name: 'My Plugin',
  Component: MyPanel,
})

// CORRECT
const [MyPlugin, NoOpPlugin] = createVuePlugin('My Plugin', MyPanel)

Vue plugins also work differently at call time -- you pass props:

// WRONG -- calling Plugin() with no args (React pattern)
const plugin = MyPlugin()

// CORRECT -- Vue Plugin takes props
const plugin = MyPlugin({ theme: 'dark' })

CRITICAL: Solid Render Prop Not Wrapped in Function

When using Solid components, Component must be a function reference, not raw JSX.

// WRONG -- evaluates immediately, breaks Solid reactivity
createSolidPlugin({
  name: 'My Store',
  Component: <MyPanel />, // This is JSX.Element, not a component function
})

// CORRECT -- pass the component function itself
createSolidPlugin({
  name: 'My Store',
  Component: (props) => <MyPanel theme={props.theme} />,
})

// ALSO CORRECT -- pass the component reference directly
createSolidPlugin({
  name: 'My Store',
  Component: MyPanel,
})

HIGH: Ignoring NoOp Variant for Production

The factory returns [Plugin, NoOpPlugin]. Both must be destructured and used for proper tree-shaking.

// WRONG -- NoOp variant discarded, devtools code ships to production
const [MyPlugin] = createReactPlugin({ name: 'Store', Component: MyPanel })

// CORRECT -- conditionally use NoOp in production
const [MyPlugin, NoOpPlugin] = createReactPlugin({
  name: 'Store',
  Component: MyPanel,
})
const ActivePlugin =
  process.env.NODE_ENV === 'development' ? MyPlugin : NoOpPlugin

MEDIUM: Not Passing Theme Prop to Panel Component

DevtoolsPanelProps includes theme. The devtools shell passes it so panels can match light/dark mode. If your component ignores it, the panel will not adapt to theme changes.

// WRONG -- theme is ignored
const Component = () => <div>My Panel</div>

// CORRECT -- use theme for styling
const Component = ({ theme }: DevtoolsPanelProps) => (
  <div className={theme === 'dark' ? 'dark-mode' : 'light-mode'}>My Panel</div>
)

Design Tension

The core architecture is framework-agnostic, but each framework has different idioms:

Agents trained on React patterns will get Vue wrong. Always check the import path to determine which factory API to use.

Cross-References

Reference Files

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.