Repository navigation
chore(examples): move the SSE chat example to TanStack Start - #7755
Conversation
Co-authored-by: alexander <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
6 Skipped Deployments
|
|
No actionable comments were generated in the recent review.
|
| 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
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
useSubscriptionlifecycle used by the migrated chat example. - trpc/trpc#7724: Updates SSE stream decoding and
EventSourcehandling 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: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull 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.
…pm alias Co-authored-by: alexander <[email protected]>
@trpc/client
@trpc/next
@trpc/openapi
@trpc/react-query
@trpc/server
@trpc/tanstack-react-query
@trpc/upgrade
commit: |
…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]>
|
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. |
Why
examples/next-sse-chat) from Next.js to TanStack Start.What
tanstackStart(), plusnitro()to build Vercel Build Output.src/routes, with a generatedrouteTree.gen.ts./api/trpc/$and/api/auth/$are server routes.src/queries.ts).useSuspenseQuery/useSuspenseInfiniteQuery.defaultPreload: 'intent'anddefaultPreloadStaleTime: 0.@tanstack/react-router-ssr-querydehydrates and streams the query cache.@trpc/tanstack-react-query(useTRPC,queryOptions,subscriptionOptions) instead of@trpc/react-query.unstable_localLinkcalls procedures in-process with the page request.httpSubscriptionLinkandhttpBatchStreamLinkat/api/trpc.createContextnow takes{ req }and reads the session from the request.callerexport in_app.tsis removed.next-authis replaced by@auth/core, the Auth.js core thatnext-authwraps. Same providers, same/api/auth/*URLs, same callback URL (/api/auth/callback/github).NEXTAUTH_SECRET,AUTH_GITHUB_ID/AUTH_GITHUB_SECRET,AUTH_TRUST_HOST).vercel.jsonsets"framework": "tanstack-start".@tanstack/react-router-ssr-queryneeds@tanstack/react-query5.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.resolve.dedupeand a tsconfig path make the linked@trpc/tanstack-react-queryuse that same copy.seroval/seroval-pluginspair. A mismatched pair breaks SSR serialization.turbo.jsondeclares this example's build outputs.routeTree.gen.tsis added to.prettierignore.Links
/: channel list is prefetched in the route loader and server-rendered./channels/<id>: posts are prefetched; new posts and "is typing" arrive over SSE.Alternatives considered
@raf-query/reactpackage directly. Not chosen: it is 0.x. This follows its loader/component split with TanStack Query, which tRPC already supports./api/trpcduring SSR. Not chosen: protected previews block it, and it adds a network round trip.unstable_localLinkavoids both.@tanstack/react-queryacross the whole repo. Not chosen: it touches every example and the tRPC packages' dev dependencies. The npm alias keeps the change inside this example.trpc/examples-next-sse-chatand linked from docs. Kept the name to avoid churn.Testing
pnpm turbo --filter=./examples/next-sse-chat typecheck lint build, pluspnpm manypkg check.whoIsTypingupdates.redirect_uri=…/api/auth/callback/github, unchanged.skills/directory: it rejects frontmatter keys already used inpackages/client/skills. That failure is not from this change.Need help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit