|
| 1 | +--- |
| 2 | +title: Devtools |
| 3 | +id: devtools |
| 4 | +--- |
| 5 | + |
| 6 | +What? My debouncer can have dedicated devtools? Yep! |
| 7 | + |
| 8 | +TanStack Pacer provides devtools for debugging and monitoring all your utilities in real-time. The devtools integrate seamlessly within the new [TanStack Devtools](https://tanstack.com/devtools) multi-panel UI. |
| 9 | + |
| 10 | +> [!NOTE] By default, the TanStack Devtools and TanStack Pacer Devtools will only be included in development mode. This helps keep your production bundle size minimal. If you need to include devtools in production builds (e.g., for debugging production issues), you can use the alternative "production" imports. |
| 11 | +
|
| 12 | +## Installation |
| 13 | + |
| 14 | +Install the devtools packages for your framework: |
| 15 | + |
| 16 | +### React |
| 17 | + |
| 18 | +```sh |
| 19 | +npm install @tanstack/react-devtools @tanstack/react-pacer-devtools |
| 20 | +``` |
| 21 | + |
| 22 | +### Solid |
| 23 | + |
| 24 | +```sh |
| 25 | +npm install @tanstack/solid-devtools @tanstack/solid-pacer-devtools |
| 26 | +``` |
| 27 | + |
| 28 | +## Basic Setup |
| 29 | + |
| 30 | +### React Setup |
| 31 | + |
| 32 | +```tsx |
| 33 | +import { TanStackDevtools } from '@tanstack/react-devtools' |
| 34 | +import { PacerDevtoolsPanel } from '@tanstack/react-pacer-devtools' |
| 35 | + |
| 36 | +function App() { |
| 37 | + return ( |
| 38 | + <div> |
| 39 | + {/* Your app content */} |
| 40 | + |
| 41 | + <TanStackDevtools |
| 42 | + eventBusConfig={{ |
| 43 | + debug: false, |
| 44 | + }} |
| 45 | + plugins={[{ name: 'TanStack Pacer', render: <PacerDevtoolsPanel /> }]} |
| 46 | + /> |
| 47 | + </div> |
| 48 | + ) |
| 49 | +} |
| 50 | +``` |
| 51 | + |
| 52 | +### Solid Setup |
| 53 | + |
| 54 | +```tsx |
| 55 | +import { TanStackDevtools } from '@tanstack/solid-devtools' |
| 56 | +import { PacerDevtoolsPanel } from '@tanstack/solid-pacer-devtools' |
| 57 | + |
| 58 | +function App() { |
| 59 | + return ( |
| 60 | + <div> |
| 61 | + {/* Your app content */} |
| 62 | + |
| 63 | + <TanStackDevtools |
| 64 | + eventBusConfig={{ |
| 65 | + debug: false, |
| 66 | + }} |
| 67 | + plugins={[{ name: 'TanStack Pacer', render: <PacerDevtoolsPanel /> }]} |
| 68 | + /> |
| 69 | + </div> |
| 70 | + ) |
| 71 | +} |
| 72 | +``` |
| 73 | + |
| 74 | +## Production Builds |
| 75 | + |
| 76 | +By default, devtools are excluded from production builds to minimize bundle size. The default imports will return no-op implementations in production: |
| 77 | + |
| 78 | +```tsx |
| 79 | +// This will be a no-op in production builds |
| 80 | +import { PacerDevtoolsPanel } from '@tanstack/react-pacer-devtools' |
| 81 | +``` |
| 82 | + |
| 83 | +If you need to include devtools in production builds (e.g., for debugging production issues), use the production-specific imports: |
| 84 | + |
| 85 | +```tsx |
| 86 | +// This will include full devtools even in production builds |
| 87 | +import { PacerDevtoolsPanel } from '@tanstack/react-pacer-devtools/production' |
| 88 | +``` |
| 89 | + |
| 90 | +## Registering Utilities |
| 91 | + |
| 92 | +Each utility should automatically be detected and displayed in the devtools. However, if you don't provide a `key` option to the utility, it will show with a uuid for its name. Give it an identifiable name with the `key` option. |
| 93 | + |
| 94 | +```tsx |
| 95 | +const debouncer = new Debouncer(myDebounceFn, { |
| 96 | + key: 'My Debouncer', // friendly name for the utility instead of auto-generated uuid |
| 97 | + wait: 1000, |
| 98 | +}) |
| 99 | +``` |
0 commit comments