You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/getting-started/devtools.md
+24-1Lines changed: 24 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,4 +53,27 @@ const App = () => {
53
53
</>
54
54
)
55
55
}
56
-
```
56
+
```
57
+
58
+
## Using with Next.js (or without a Vite plugin)
59
+
60
+
`connectToServerBus: true` relies on a WebSocket/SSE server on port 4206 that is normally started by `@tanstack/devtools-vite`. If you're using Next.js (or any non-Vite bundler), you need to start `ServerEventBus` manually at server boot.
61
+
62
+
In Next.js, do this in `instrumentation.ts`:
63
+
64
+
```ts
65
+
exportasyncfunction register() {
66
+
if (
67
+
process.env["NEXT_RUNTIME"] ==="nodejs"&&
68
+
process.env.NODE_ENV==="development"
69
+
) {
70
+
const { ServerEventBus } =awaitimport(
71
+
"@tanstack/devtools-event-bus/server"
72
+
);
73
+
const bus =newServerEventBus();
74
+
awaitbus.start();
75
+
}
76
+
}
77
+
```
78
+
79
+
This sets globalThis.__TANSTACK_EVENT_TARGET__ so the server-side devtoolsMiddleware (which runs automatically inside every chat() call) can emit tool call events to the bus, which then forwards them to the devtools panel.
0 commit comments