Skip to content

Add devtools usage in NextJS#454

Merged
AlemTuzlak merged 3 commits intoTanStack:mainfrom
oskarscholander:patch-2
Apr 15, 2026
Merged

Add devtools usage in NextJS#454
AlemTuzlak merged 3 commits intoTanStack:mainfrom
oskarscholander:patch-2

Conversation

@oskarscholander
Copy link
Copy Markdown
Contributor

@oskarscholander oskarscholander commented Apr 15, 2026

🎯 Changes

This adds a section about how to run the SSE bus in NextJS

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Documentation
    • Added guidance for using the devtools with Next.js and other non‑Vite bundlers, including instructions for enabling a server-side event bus during development.
    • Included a conditional example showing how to initialize the server-side event bus only on the Node/dev server.
    • Minor formatting fix (trailing newline).

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0545f995-2feb-440e-b214-fbcc9c0e183a

📥 Commits

Reviewing files that changed from the base of the PR and between b4c6e47 and 1bd5a14.

📒 Files selected for processing (1)
  • docs/getting-started/devtools.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/getting-started/devtools.md

📝 Walkthrough

Walkthrough

Adds a documentation section to docs/getting-started/devtools.md that explains using eventBusConfig={{ connectToServerBus: true }} with Next.js and other non‑Vite bundlers, and includes an instrumentation.ts example that conditionally imports and starts ServerEventBus in Node during development.

Changes

Cohort / File(s) Summary
Documentation Update
docs/getting-started/devtools.md
Appends "Using with Next.js (or without a Vite plugin)" section clarifying that connectToServerBus: true expects a WebSocket/SSE server (port 4206 by default), provides a conditional @tanstack/devtools-event-bus/server import and ServerEventBus instantiation example for Node/dev, and adds a trailing newline.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 I hopped into docs with curious cheer,

"Start ServerEventBus when Node is near,"
Dev-only imports, a conditional art,
Websockets listen, the events depart,
Hooray — the rabbit thumps, docs clear! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the main change - adding devtools usage documentation for NextJS, which matches the core objective of the PR.
Description check ✅ Passed The description follows the required template structure with all main sections completed, including a clear explanation of changes and proper release impact designation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Apr 15, 2026

View your CI Pipeline Execution ↗ for commit 1bd5a14

Command Status Duration Result
nx run-many --targets=build --exclude=examples/** ✅ Succeeded 2s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-15 19:21:08 UTC

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 15, 2026

Open in StackBlitz

@tanstack/ai

npm i https://pkg.pr.new/@tanstack/ai@454

@tanstack/ai-anthropic

npm i https://pkg.pr.new/@tanstack/ai-anthropic@454

@tanstack/ai-client

npm i https://pkg.pr.new/@tanstack/ai-client@454

@tanstack/ai-code-mode

npm i https://pkg.pr.new/@tanstack/ai-code-mode@454

@tanstack/ai-code-mode-skills

npm i https://pkg.pr.new/@tanstack/ai-code-mode-skills@454

@tanstack/ai-devtools-core

npm i https://pkg.pr.new/@tanstack/ai-devtools-core@454

@tanstack/ai-elevenlabs

npm i https://pkg.pr.new/@tanstack/ai-elevenlabs@454

@tanstack/ai-event-client

npm i https://pkg.pr.new/@tanstack/ai-event-client@454

@tanstack/ai-fal

npm i https://pkg.pr.new/@tanstack/ai-fal@454

@tanstack/ai-gemini

npm i https://pkg.pr.new/@tanstack/ai-gemini@454

@tanstack/ai-grok

npm i https://pkg.pr.new/@tanstack/ai-grok@454

@tanstack/ai-groq

npm i https://pkg.pr.new/@tanstack/ai-groq@454

@tanstack/ai-isolate-cloudflare

npm i https://pkg.pr.new/@tanstack/ai-isolate-cloudflare@454

@tanstack/ai-isolate-node

npm i https://pkg.pr.new/@tanstack/ai-isolate-node@454

@tanstack/ai-isolate-quickjs

npm i https://pkg.pr.new/@tanstack/ai-isolate-quickjs@454

@tanstack/ai-ollama

npm i https://pkg.pr.new/@tanstack/ai-ollama@454

@tanstack/ai-openai

npm i https://pkg.pr.new/@tanstack/ai-openai@454

@tanstack/ai-openrouter

npm i https://pkg.pr.new/@tanstack/ai-openrouter@454

@tanstack/ai-preact

npm i https://pkg.pr.new/@tanstack/ai-preact@454

@tanstack/ai-react

npm i https://pkg.pr.new/@tanstack/ai-react@454

@tanstack/ai-react-ui

npm i https://pkg.pr.new/@tanstack/ai-react-ui@454

@tanstack/ai-solid

npm i https://pkg.pr.new/@tanstack/ai-solid@454

@tanstack/ai-solid-ui

npm i https://pkg.pr.new/@tanstack/ai-solid-ui@454

@tanstack/ai-svelte

npm i https://pkg.pr.new/@tanstack/ai-svelte@454

@tanstack/ai-vue

npm i https://pkg.pr.new/@tanstack/ai-vue@454

@tanstack/ai-vue-ui

npm i https://pkg.pr.new/@tanstack/ai-vue-ui@454

@tanstack/preact-ai-devtools

npm i https://pkg.pr.new/@tanstack/preact-ai-devtools@454

@tanstack/react-ai-devtools

npm i https://pkg.pr.new/@tanstack/react-ai-devtools@454

@tanstack/solid-ai-devtools

npm i https://pkg.pr.new/@tanstack/solid-ai-devtools@454

commit: 1bd5a14

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/getting-started/devtools.md`:
- Around line 64-79: Close the open TypeScript fenced block after the register
function so the explanatory paragraph renders as text: add a closing ```
immediately after the end of the export async function register() { ... } block
(i.e., after the await bus.start(); }), and remove the stray extra closing fence
at the end so there's only one proper closing ``` separating the code and the
paragraph; reference the register function and the surrounding ts fenced block
to locate the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d7af1597-56df-48f5-86fd-b13a9cf90f6a

📥 Commits

Reviewing files that changed from the base of the PR and between cf19b8a and 0a7ef01.

📒 Files selected for processing (1)
  • docs/getting-started/devtools.md

Comment thread docs/getting-started/devtools.md Outdated
Comment thread docs/getting-started/devtools.md Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
docs/getting-started/devtools.md (1)

64-76: ⚠️ Potential issue | 🔴 Critical

Close the TypeScript code block and add the explanatory paragraph.

The TypeScript code block that opens at line 64 is never closed. This will cause the Markdown to render incorrectly—any content after the code block will be treated as code instead of text. Additionally, based on past review suggestions, an explanatory paragraph about what the code accomplishes is missing.

📝 Proposed fix to close the code block and add explanation
          const bus = new ServerEventBus();
          await bus.start();
      }
 }
+```
+
+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.

As per coding guidelines, "docs/**/*.md: Use Markdown for documentation in the docs/ directory with auto-generated docs via TypeDoc".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/getting-started/devtools.md` around lines 64 - 76, The TypeScript code
block opened in register() is not closed and lacks the explanatory paragraph;
close the fenced code block after the shown code and add a brief paragraph
explaining that the snippet sets globalThis.__TANSTACK_EVENT_TARGET__ so the
server-side devtoolsMiddleware (which runs automatically inside every chat()
call) can emit tool call events to the ServerEventBus and forward them to the
devtools panel; ensure the explanation references ServerEventBus and the
bus.start() behavior and appears immediately after the closed code fence.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@docs/getting-started/devtools.md`:
- Around line 64-76: The TypeScript code block opened in register() is not
closed and lacks the explanatory paragraph; close the fenced code block after
the shown code and add a brief paragraph explaining that the snippet sets
globalThis.__TANSTACK_EVENT_TARGET__ so the server-side devtoolsMiddleware
(which runs automatically inside every chat() call) can emit tool call events to
the ServerEventBus and forward them to the devtools panel; ensure the
explanation references ServerEventBus and the bus.start() behavior and appears
immediately after the closed code fence.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e4cda598-b0ae-4964-b258-0b86a2f1f5f1

📥 Commits

Reviewing files that changed from the base of the PR and between 0a7ef01 and b4c6e47.

📒 Files selected for processing (1)
  • docs/getting-started/devtools.md

@AlemTuzlak AlemTuzlak merged commit 5f0beaf into TanStack:main Apr 15, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants