Skip to content

chore(examples): move the SSE chat example to TanStack Start - #7755

Merged
KATT merged 3 commits into
mainfrom
cursor/sse-tanstack-start-0ee9
Oct 31, 2026
Merged

KATT merged 3 commits into
mainfrom
cursor/sse-tanstack-start-0ee9

Conversation

@KATT

@KATT KATT commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Why

  • Moves the SSE chat example (examples/next-sse-chat) from Next.js to TanStack Start.
  • The tRPC side stays the same: same router, procedures, SSE subscriptions and browser links. Only the framework glue changes.

What

  • Framework
    • Vite with tanstackStart(), plus nitro() to build Vercel Build Output.
    • File routes in src/routes, with a generated routeTree.gen.ts.
    • /api/trpc/$ and /api/auth/$ are server routes.
  • Data loading, in the style of raf-query
    • Route loaders prefetch the page's queries (src/queries.ts).
    • Components only read them, with useSuspenseQuery / useSuspenseInfiniteQuery.
    • The router has defaultPreload: 'intent' and defaultPreloadStaleTime: 0.
    • @tanstack/react-router-ssr-query dehydrates and streams the query cache.
  • tRPC client
    • Uses @trpc/tanstack-react-query (useTRPC, queryOptions, subscriptionOptions) instead of @trpc/react-query.
    • During SSR, unstable_localLink calls procedures in-process with the page request.
    • The browser keeps the same links: httpSubscriptionLink and httpBatchStreamLink at /api/trpc.
  • tRPC server glue
    • createContext now takes { req } and reads the session from the request.
    • The RSC-only caller export in _app.ts is removed.
    • Routers and procedures are unchanged.
  • Auth
    • next-auth is replaced by @auth/core, the Auth.js core that next-auth wraps. Same providers, same /api/auth/* URLs, same callback URL (/api/auth/callback/github).
    • Same env vars (NEXTAUTH_SECRET, AUTH_GITHUB_ID/AUTH_GITHUB_SECRET, AUTH_TRUST_HOST).
    • Sign in and sign out use the built-in Auth.js pages.
  • Deploy
    • vercel.json sets "framework": "tanstack-start".
    • Region, fluid compute and install/build commands are unchanged.
    • Database and pub/sub code are untouched, so preview schema isolation and channel scoping keep working.
  • Dependencies
    • @tanstack/react-router-ssr-query needs @tanstack/react-query 5.102 or newer. The rest of the repo uses ^5.80.3, and manypkg would pull it back. The example pins it with an npm alias (npm:@tanstack/react-query@^5.105.0), which manypkg skips.
    • Vite resolve.dedupe and a tsconfig path make the linked @trpc/tanstack-react-query use that same copy.
    • The lockfile pins a matching seroval / seroval-plugins pair. A mismatched pair breaks SSR serialization.
    • turbo.json declares this example's build outputs.
  • Docs
    • Removed this example from the Next.js App Router starter list, the App Router setup guide and the Next.js App Router skill sources.
    • routeTree.gen.ts is added to .prettierignore.

Links

  • SSE chat home: /: channel list is prefetched in the route loader and server-rendered.
  • SSE chat channel: /channels/<id>: posts are prefetched; new posts and "is typing" arrive over SSE.

Alternatives considered

  • Use the @raf-query/react package directly. Not chosen: it is 0.x. This follows its loader/component split with TanStack Query, which tRPC already supports.
  • Self-fetch /api/trpc during SSR. Not chosen: protected previews block it, and it adds a network round trip. unstable_localLink avoids both.
  • Bump @tanstack/react-query across the whole repo. Not chosen: it touches every example and the tRPC packages' dev dependencies. The npm alias keeps the change inside this example.
  • Rename the example directory. Not chosen: it is published to trpc/examples-next-sse-chat and linked from docs. Kept the name to avoid churn.

Testing

  • pnpm turbo --filter=./examples/next-sse-chat typecheck lint build, plus pnpm manypkg check.
  • Ran the production build locally against Postgres. On the Vercel preview, checked with curl and headless Chromium:
    • Pages server-render with prefetched channels and posts.
    • Mocked GitHub sign-in works through the Auth.js page.
    • The subscription connects; a post from another client appears live, and so does one sent from the page.
    • whoIsTyping updates.
    • An invalid channel id returns 404.
    • No hydration or script errors.
  • With GitHub credentials set, sign-in redirects to GitHub with redirect_uri=…/api/auth/callback/github, unchanged.
  • No server code (database, router, auth) ends up in the browser bundle.
  • "Validate skill files" fails on every PR that touches a skills/ directory: it rejects frontmatter keys already used in packages/client/skills. That failure is not from this change.
Open in Web Open in Cursor 

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

Summary by CodeRabbit

  • New Features
    • Updated the SSE chat example to use TanStack Start, with channel navigation, live chat updates, and sign-in support. GitHub sign-in is optional; without provider credentials, the example offers mock sign-in.
  • Documentation
    • Updated the example guide to explain server-side data loading and browser requests.
    • Removed the SSE chat example from the Next.js App Router starter-project listings.

@KATT
KATT requested review from a team as code owners October 31, 2026 21:23
@vercel

vercel Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
next-sse-chat Ready Ready Preview Oct 31, 2026 9:30pm UTC
6 Skipped Deployments
Project Deployment Actions Updated
examples-todomvc Skipped Skipped Oct 31, 2026 9:30pm UTC
next-prisma-starter Skipped Skipped Oct 31, 2026 9:30pm UTC
next-prisma-websockets-starter Skipped Skipped Oct 31, 2026 9:30pm UTC
og-image Skipped Skipped Oct 31, 2026 9:30pm UTC
trpc-next-app-dir Skipped Skipped Oct 31, 2026 9:30pm UTC
www Skipped Skipped Oct 31, 2026 9:30pm UTC

Request Review

@vercel
vercel Bot temporarily deployed to Preview – www October 31, 2026 21:24 Inactive
@vercel
vercel Bot temporarily deployed to Preview – trpc-next-app-dir October 31, 2026 21:24 Inactive
@vercel
vercel Bot temporarily deployed to Preview – og-image October 31, 2026 21:24 Inactive
@vercel
vercel Bot temporarily deployed to Preview – next-prisma-starter October 31, 2026 21:24 Inactive
@vercel
vercel Bot temporarily deployed to Preview – examples-todomvc October 31, 2026 21:24 Inactive
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between cf82c25 and ca302c5.

Files ignored due to path filters: 1
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing: 38
  • .prettierignore
  • _artifacts/skill_tree.yaml
  • examples/next-sse-chat/.env.example
  • examples/next-sse-chat/.gitignore
  • examples/next-sse-chat/README.md
  • examples/next-sse-chat/next.config.ts
  • examples/next-sse-chat/package.json
  • examples/next-sse-chat/src/app/api/auth/[...nextauth]/route.ts
  • examples/next-sse-chat/src/app/channels/[channelId]/layout.tsx
  • examples/next-sse-chat/src/app/channels/[channelId]/page.tsx
  • examples/next-sse-chat/src/app/layout.tsx
  • examples/next-sse-chat/src/app/providers.tsx
  • examples/next-sse-chat/src/components/auth.tsx
  • examples/next-sse-chat/src/components/create-channel.tsx
  • examples/next-sse-chat/src/lib/trpc.ts
  • examples/next-sse-chat/src/queries.ts
  • examples/next-sse-chat/src/routeTree.gen.ts
  • examples/next-sse-chat/src/router.tsx
  • examples/next-sse-chat/src/routes/__root.tsx
  • examples/next-sse-chat/src/routes/api/auth.$.ts
  • examples/next-sse-chat/src/routes/api/trpc.$.ts
  • examples/next-sse-chat/src/routes/channels/$channelId.tsx
  • examples/next-sse-chat/src/routes/channels/-components/chat.tsx
  • examples/next-sse-chat/src/routes/channels/-components/hooks.ts
  • examples/next-sse-chat/src/routes/channels/-components/utils.ts
  • examples/next-sse-chat/src/routes/index.tsx
  • examples/next-sse-chat/src/server/auth.ts
  • examples/next-sse-chat/src/server/context.ts
  • examples/next-sse-chat/src/server/routers/_app.ts
  • examples/next-sse-chat/src/styles.css
  • examples/next-sse-chat/tailwind.config.ts
  • examples/next-sse-chat/tsconfig.json
  • examples/next-sse-chat/vercel.json
  • examples/next-sse-chat/vite.config.ts
  • packages/next/skills/nextjs-app-router/SKILL.md
  • turbo.json
  • www/docs/client/nextjs/app-router/setup.mdx
  • www/docs/client/nextjs/starter-projects.md
Files with no reviewable changes: 11
  • _artifacts/skill_tree.yaml
  • www/docs/client/nextjs/app-router/setup.mdx
  • examples/next-sse-chat/src/app/api/auth/[...nextauth]/route.ts
  • packages/next/skills/nextjs-app-router/SKILL.md
  • examples/next-sse-chat/src/app/channels/[channelId]/page.tsx
  • examples/next-sse-chat/src/app/channels/[channelId]/layout.tsx
  • examples/next-sse-chat/next.config.ts
  • examples/next-sse-chat/src/app/providers.tsx
  • www/docs/client/nextjs/starter-projects.md
  • examples/next-sse-chat/src/server/routers/_app.ts
  • examples/next-sse-chat/src/app/layout.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Walkthrough

The next-sse-chat example migrates from Next.js to TanStack Start and from NextAuth to Auth.js. It adds TanStack Router routes and query prefetching, updates tRPC server and browser integrations, and migrates the chat UI and build configuration.

Changes: SSE chat example migration

Layer / File(s) Summary
TanStack Start app and build setup
.prettierignore, _artifacts/skill_tree.yaml, examples/next-sse-chat/{.env.example,.gitignore,README.md,package.json,tsconfig.json,vite.config.ts,vercel.json}, examples/next-sse-chat/next.config.ts, examples/next-sse-chat/src/app/layout.tsx, examples/next-sse-chat/src/routeTree.gen.ts, examples/next-sse-chat/src/router.tsx, examples/next-sse-chat/src/routes/__root.tsx, examples/next-sse-chat/src/styles.css, examples/next-sse-chat/tailwind.config.ts, packages/next/skills/nextjs-app-router/SKILL.md, turbo.json, www/docs/client/nextjs/*
The example adds TanStack Start, Vite, and router setup, including a generated route tree and root route. Build settings and the README are updated, and the example is removed from the Next.js App Router skill sources and documentation listings.
Auth and tRPC request handling
examples/next-sse-chat/src/lib/trpc.ts, examples/next-sse-chat/src/server/{auth.ts,context.ts,routers/_app.ts}, examples/next-sse-chat/src/routes/api/*, examples/next-sse-chat/src/app/api/auth/[...nextauth]/route.ts, examples/next-sse-chat/src/app/providers.tsx
Auth.js handles auth requests and request-based session lookup. tRPC uses a typed TanStack Query integration, with local server calls and browser requests routed through /api/trpc.
Route data and chat UI
examples/next-sse-chat/src/queries.ts, examples/next-sse-chat/src/components/{auth.tsx,create-channel.tsx}, examples/next-sse-chat/src/routes/{index.tsx,channels/*}, examples/next-sse-chat/src/app/channels/[channelId]/*
The home and channel routes prefetch query data and render channel navigation and chat controls. Chat subscriptions and mutations use TanStack Query options, and authentication controls use the new client helpers.

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  participant TanStackRouter
  participant QueryClient
  participant makeTRPCClient
  participant appRouter
  participant TRPCRoute
  participant fetchRequestHandler
  TanStackRouter->>QueryClient: Prefetch route query
  QueryClient->>makeTRPCClient: Execute tRPC query options
  alt Server runtime
    makeTRPCClient->>appRouter: Call procedure through local link with request context
  else Browser runtime
    makeTRPCClient->>TRPCRoute: Send request to /api/trpc
    TRPCRoute->>fetchRequestHandler: Pass request to tRPC handler
  end
Loading

Possibly related PRs

  • trpc/trpc#7754: Migrates the same example from Next.js to TanStack Start and updates its Vercel framework.
  • trpc/trpc#7743: Changes the useSubscription lifecycle used by the migrated chat example.
  • trpc/trpc#7724: Updates SSE stream decoding and EventSource handling used by browser subscriptions.

Suggested reviewers: juliusmarminge

Merge Risk: Minimal · up to ca302

The documented development setup and Vercel preset selection show no identified merge blocker. Production deployments still need authentication secrets in their runtime environment.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: moving the SSE chat example from its current framework to TanStack Start.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 6 functions across 17 files. (9 skipped: 9 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@vercel
vercel Bot temporarily deployed to Preview – next-prisma-starter October 31, 2026 21:27 Inactive
@vercel
vercel Bot temporarily deployed to Preview – examples-todomvc October 31, 2026 21:27 Inactive
@vercel
vercel Bot temporarily deployed to Preview – www October 31, 2026 21:27 Inactive
@vercel
vercel Bot temporarily deployed to Preview – og-image October 31, 2026 21:27 Inactive
@vercel
vercel Bot temporarily deployed to Preview – trpc-next-app-dir October 31, 2026 21:27 Inactive
@pkg-pr-new

pkg-pr-new Bot commented Oct 31, 2026

Copy link
Copy Markdown

Open in StackBlitz

@trpc/client

npm i https://pkg.pr.new/@trpc/client@7755

@trpc/next

npm i https://pkg.pr.new/@trpc/next@7755

@trpc/openapi

npm i https://pkg.pr.new/@trpc/openapi@7755

@trpc/react-query

npm i https://pkg.pr.new/@trpc/react-query@7755

@trpc/server

npm i https://pkg.pr.new/@trpc/server@7755

@trpc/tanstack-react-query

npm i https://pkg.pr.new/@trpc/tanstack-react-query@7755

@trpc/upgrade

npm i https://pkg.pr.new/@trpc/upgrade@7755

commit: ca302c5

@KATT
KATT added this pull request to the merge queue Oct 31, 2026
Merged via the queue into main with commit 85bcf32 Oct 31, 2026
54 of 55 checks passed
@KATT
KATT deleted the cursor/sse-tanstack-start-0ee9 branch October 31, 2026 21:46
opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-trpc__trpc that referenced this pull request Oct 31, 2026
…c#7756)

## Why

- `examples/next-sse-chat` runs on TanStack Start since trpc#7755, so the
name is wrong.

## What

- Move `examples/next-sse-chat` to `examples/tanstack-start-sse-chat`
and rename the package to `examples-tanstack-start-sse-chat`.
- Point the `buildCommand` in `vercel.json` and the turbo task key at
the new name.
- Update the `subtree.yml` matrix entry and the commented entry in
`main.yml`. The subtree now mirrors to
`trpc/examples-tanstack-start-sse-chat`.
- Update links in the example's README and home page, and in the docs.
- The downstream repo is already renamed from
`trpc/examples-next-sse-chat` to
`trpc/examples-tanstack-start-sse-chat`. The old URL redirects.

The `next-sse-chat` Vercel project Root Directory is already set to
`examples/tanstack-start-sse-chat`.

## Links

- Docs: [Example
Apps](https://www-git-t3-rename-next-sse-chat-to-sse-chat-trpc.vercel.app/docs/main/example-apps)
  - SSE Chat row: source and CodeSandbox links.
- Docs:
[Subscriptions](https://www-git-t3-rename-next-sse-chat-to-sse-chat-trpc.vercel.app/docs/server/subscriptions)
- Docs:
[WebSockets](https://www-git-t3-rename-next-sse-chat-to-sse-chat-trpc.vercel.app/docs/server/websockets)
- Docs:
[useSubscription](https://www-git-t3-rename-next-sse-chat-to-sse-chat-trpc.vercel.app/docs/client/react/useSubscription)
- Docs: [Awesome
tRPC](https://www-git-t3-rename-next-sse-chat-to-sse-chat-trpc.vercel.app/docs/community/awesome-trpc)

## Alternatives considered

- None

## Testing

- `pnpm install --frozen-lockfile` passes. The lockfile diff only moves
the importer block.
- `pnpm typecheck-packages`, `pnpm typecheck-www`, `pnpm lint` and `pnpm
manypkg check` pass.
- `pnpm turbo --filter=./examples/tanstack-start-sse-chat typecheck
lint` passes.
- `pnpm turbo --filter=./examples/tanstack-start-sse-chat build` passes
against a local Postgres, with `--env-mode=loose` to pass `POSTGRES_URL`
through.
- `git grep next-sse-chat` finds nothing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- codesmith:footer -->
---
<a
href="https://app.blacksmith.sh/trpc/codesmith/trpc/pr/7756?autoLogin=true&ref=codesmith_pr_footer"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v3.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-light-v3.svg"><img
alt="View with [code]smith"
src="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v3-3x.png"
width="162" height="28"></picture></a> <a
href="https://backend.blacksmith.sh/track/enable-autofix?expires=1796075838&installation_model_id=443568&pr_number=7756&ref=codesmith_pr_footer&repository=trpc%2Ftrpc&return_to=https%3A%2F%2Fgithub.com%2Ftrpc%2Ftrpc%2Fpull%2F7756&signature=6734e2bbbfffc3170d1727de6a0b1d221c04ca63a6bdab30bd98321f7c3b4bc0"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-light.svg"><img
alt="Autofix with [code]smith"
src="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png"
width="190" height="28"></picture></a>
<sup>Need help on this PR? Tag <code>@codesmith-bot</code> with what you
need.</sup>

<!-- codesmith:autofix:disabled -->
<!-- /codesmith:footer -->


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Documentation**
* Updated SSE chat example links and setup instructions to point to the
TanStack Start example.
* **Chores**
* Updated build and sync configuration to use the TanStack Start SSE
chat example.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

This pull request has been locked because we are very unlikely to see comments on closed issues. If you think, this PR is still necessary, create a new one with the same branch. Thank you.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 2, 2026

This branch was previously deployed

5 inactive deployments
Preview – og-image — ca302c54 Deployed Oct 31, 2026 by vercel[bot]
Preview – trpc-next-app-dir — ca302c54 Deployed Oct 31, 2026 by vercel[bot]
Preview – next-prisma-starter — ca302c54 Deployed Oct 31, 2026 by vercel[bot]
Preview – examples-todomvc — ca302c54 Deployed Oct 31, 2026 by vercel[bot]
Preview – www — ca302c54 Deployed Oct 31, 2026 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants