Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/chubby-otters-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/devtools': minor
---

add defaultOpen to plugins
5 changes: 5 additions & 0 deletions .changeset/some-adults-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/devtools-utils': patch
---

extend the plugins to accept config
6 changes: 5 additions & 1 deletion docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
"label": "Configuration",
"to": "configuration"
},
{
"label": "Plugin Configuration",
"to": "plugin-configuration"
},
{
"label": "Installation",
"to": "installation"
Expand Down Expand Up @@ -148,4 +152,4 @@
]
}
]
}
}
1 change: 1 addition & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ createRoot(document.getElementById('root')!).render(
{
name: 'TanStack Form',
render: <FormDevtools />,
defaultOpen: true,
},
]}
/>
Expand Down
48 changes: 48 additions & 0 deletions docs/plugin-configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: Plugin Configuration
id: plugin-configuration
---


# Plugin Configuration

You can configure TanStack Devtools plugins by passing them as an array to the `plugins` prop of the `TanStackDevtools` component.

Each plugin can have the following configuration options:
- `render` (required) - A React component that renders the plugin's UI
- `defaultOpen` (optional) - A boolean that determines if the plugin panel is open by default (default: false).
- `id` (optional) - A unique identifier for the plugin. If not provided, a random id will be generated.

Here's an example of how to configure plugins in the `TanStackDevtools` component:

```tsx
import { TanStackDevtools } from '@tanstack/react-devtools'
import { FormDevtools } from '@tanstack/react-form-devtools'

function App() {
return (
<>
<YourApp />
<TanStackDevtools
plugins={[
{
name: 'TanStack Form',
render: <FormDevtools />,
defaultOpen: true,
},
]}
/>
</>
)
}
```

## Default open

You can set a plugin to be open by default by setting the `defaultOpen` property to `true` when configuring the plugin. This will make the plugin panel open when the devtools are first loaded.

If you only have 1 plugin it will automatically be opened regardless of the `defaultOpen` setting.

The limit to open plugins is at 3 panels at a time. If more than 3 plugins are set to `defaultOpen: true`, only the first 3 will be opened.

This does not override the settings saved in localStorage. If you have previously opened the plugin panel, and selected some plugins to be open or closed, those settings will take precedence over the `defaultOpen` setting.
2 changes: 2 additions & 0 deletions docs/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ function App() {
{
name: 'TanStack Query',
render: <ReactQueryDevtoolsPanel />,
defaultOpen: true
},
{
name: 'TanStack Router',
render: <TanStackRouterDevtoolsPanel />,
defaultOpen: false
},
]} />
</QueryClientProvider>
Expand Down
17 changes: 11 additions & 6 deletions packages/devtools-utils/src/react/plugin.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import type { JSX } from 'react'
import type { DevtoolsPanelProps } from './panel'

export function createReactPlugin(
name: string,
Component: (props: DevtoolsPanelProps) => JSX.Element,
) {
export function createReactPlugin({
Component,
...config
}: {
name: string
id?: string
defaultOpen?: boolean
Component: (props: DevtoolsPanelProps) => JSX.Element
}) {
function Plugin() {
return {
name: name,
config,
render: (_el: HTMLElement, theme: 'light' | 'dark') => (
<Component theme={theme} />
),
}
}
function NoOpPlugin() {
return {
name: name,
config,
render: (_el: HTMLElement, _theme: 'light' | 'dark') => <></>,
}
}
Expand Down
17 changes: 11 additions & 6 deletions packages/devtools-utils/src/solid/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,26 @@
import type { JSX } from 'solid-js'
import type { DevtoolsPanelProps } from './panel'

export function createSolidPlugin(
name: string,
Component: (props: DevtoolsPanelProps) => JSX.Element,
) {
export function createSolidPlugin({
Component,
...config
}: {
name: string
id?: string
defaultOpen?: boolean
Component: (props: DevtoolsPanelProps) => JSX.Element
}) {
function Plugin() {
return {
name: name,
...config,
render: (_el: HTMLElement, theme: 'light' | 'dark') => {
return <Component theme={theme} />
},
}
}
function NoOpPlugin() {
return {
name: name,
...config,
render: (_el: HTMLElement, _theme: 'light' | 'dark') => <></>,
}
}
Expand Down
Loading
Loading