|
| 1 | +--- |
| 2 | +title: TanStack Devtools Angular Adapter |
| 3 | +id: adapter |
| 4 | +--- |
| 5 | + |
| 6 | +The Angular adapter wraps `TanStackDevtoolsCore` in an Angular standalone component, using Angular's `createComponent` and `ApplicationRef.attachView` to dynamically render plugins into the correct DOM containers managed by the devtools shell. |
| 7 | + |
| 8 | +## Installation |
| 9 | + |
| 10 | +```sh |
| 11 | +npm install @tanstack/angular-devtools |
| 12 | +``` |
| 13 | + |
| 14 | +## Component Inputs |
| 15 | + |
| 16 | +The `TanStackDevtoolsComponent` (selector: `tanstack-devtools`) accepts the following signal-based inputs, defined by the `TanStackDevtoolsAngularInit` interface: |
| 17 | + |
| 18 | +| Input | Type | Description | |
| 19 | +| --- | --- | --- | |
| 20 | +| `plugins` | `TanStackDevtoolsAngularPlugin[]` | Array of plugins to render inside the devtools panel. | |
| 21 | +| `config` | `Partial<TanStackDevtoolsConfig>` | Configuration for the devtools shell. Sets the initial state on first load; afterwards settings are persisted in local storage. | |
| 22 | +| `eventBusConfig` | `ClientEventBusConfig` | Configuration for the TanStack Devtools client event bus. | |
| 23 | + |
| 24 | +## Plugin Type |
| 25 | + |
| 26 | +Each plugin in the `plugins` array must conform to the `TanStackDevtoolsAngularPlugin` type: |
| 27 | + |
| 28 | +```ts |
| 29 | +type TanStackDevtoolsAngularPlugin = { |
| 30 | + id?: string |
| 31 | + component: Type<any> |
| 32 | + name: string | Type<any> |
| 33 | + inputs?: Record<string, any> |
| 34 | + defaultOpen?: boolean |
| 35 | +} |
| 36 | +``` |
| 37 | +
|
| 38 | +| Field | Type | Description | |
| 39 | +| --- | --- | --- | |
| 40 | +| `id` | `string` (optional) | Unique identifier for the plugin. | |
| 41 | +| `component` | `Type<any>` | The Angular component class to render as the plugin panel content. | |
| 42 | +| `name` | `string \| Type<any>` | Display name for the tab title. Can be a plain string or an Angular component class for custom rendering. | |
| 43 | +| `inputs` | `Record<string, any>` (optional) | Additional inputs passed to the plugin component via `setInput()`. | |
| 44 | +| `defaultOpen` | `boolean` (optional) | Whether this plugin tab should be open by default. | |
| 45 | +
|
| 46 | +## Key Differences from Other Frameworks |
| 47 | +
|
| 48 | +The Angular adapter uses `component` (an Angular component class reference) instead of `render` (a JSX element) in plugin definitions. Inputs are provided through the `inputs` field and bound to the component with `setInput()`, rather than being embedded directly in a JSX expression or passed via `v-bind`. |
| 49 | +
|
| 50 | +```typescript |
| 51 | +import { Component } from '@angular/core' |
| 52 | +import { TanStackDevtoolsComponent } from '@tanstack/angular-devtools' |
| 53 | +import { AngularQueryDevtoolsPanel } from '@tanstack/angular-query-devtools' |
| 54 | + |
| 55 | +@Component({ |
| 56 | + selector: 'app-root', |
| 57 | + standalone: true, |
| 58 | + imports: [TanStackDevtoolsComponent], |
| 59 | + template: ` |
| 60 | + <tanstack-devtools [plugins]="plugins" /> |
| 61 | + `, |
| 62 | +}) |
| 63 | +export class AppComponent { |
| 64 | + plugins = [ |
| 65 | + { |
| 66 | + name: 'Angular Query', |
| 67 | + component: AngularQueryDevtoolsPanel, |
| 68 | + inputs: { style: 'height: 100%' }, |
| 69 | + }, |
| 70 | + ] |
| 71 | +} |
| 72 | +``` |
| 73 | + |
| 74 | +## Exports |
| 75 | + |
| 76 | +The `@tanstack/angular-devtools` package exports: |
| 77 | + |
| 78 | +- **`TanStackDevtoolsComponent`** -- The main Angular standalone component that renders the devtools panel. |
| 79 | +- **`TanStackDevtoolsAngularPlugin`** (type) -- The type for plugin definitions. |
| 80 | +- **`TanStackDevtoolsAngularInit`** (type) -- The inputs interface for the `TanStackDevtoolsComponent`. |
| 81 | + |
| 82 | +The package depends on `@tanstack/devtools` (the core package), which provides `TanStackDevtoolsCore`, `TanStackDevtoolsConfig`, `ClientEventBusConfig`, and other core utilities. |
0 commit comments