Repository navigation
docs(next): use TanStack React Query in Next.js docs, deprecate react-query-based helpers - #7830
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Deprecation notices and migration guidance packages/next/README.md, packages/next/src/*, www/v11/docs/client/nextjs.md, www/v11/docs/client/react/useQuery.md |
Package comments and documentation mark classic Pages Router helpers as deprecated and direct readers to TanStack React Query migration guidance. The experimental App Router helpers are distinguished from the deprecated APIs. |
Pages Router client setup and query use www/v11/docs/client/nextjs/pages-router/setup.md, www/v11/docs/client/nextjs/pages-router/aborting-procedure-calls.md, www/v11/docs/client/nextjs/app-router-setup.md |
Setup examples use TanStack React Query providers and query options. The aborting guide shows query-level cancellation. Query examples render pending, error, and success states. |
Page prefetching, hydration, and rendering www/v11/docs/client/nextjs/pages-router/server-side-helpers.md, www/v11/docs/client/nextjs/pages-router/ssg.md, www/v11/docs/client/nextjs/pages-router/ssr.md |
The guides use query-option proxies and query clients for server-side and static-generation prefetching. They document dehydrated state, error handling, and query rendering. |
Related Next.js integration guidance www/v11/docs/client.md, www/v11/docs/client/links/httpBatchLink.md, www/v11/docs/server/caching.md |
The client overview and HTTP batch link guidance point Next.js users to the TanStack React Query integration. The caching note links to the Pages Router SSR guide. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Other
Possibly related issues
- trpc/trpc#7596: The PR updates Next.js documentation to use
@trpc/tanstack-react-queryand changes App Router examples. - trpc/trpc#3708: The SSR guidance documents request-derived context for server-side tRPC calls.
- trpc/trpc#4448: The aborting guide documents query-level
abortOnUnmountbehavior.
Possibly related PRs
- trpc/trpc#7805: This PR also addresses the Pages Router migration to TanStack React Query.
- trpc/trpc#7804: This PR marks classic React Query APIs deprecated in favor of TanStack React Query, which this PR applies to Next.js helpers and guides.
- trpc/trpc#7829: This PR distinguishes experimental App Router helpers from deprecated Pages Router helpers.
Suggested reviewers: juliusmarminge, nick-lucas
Merge Risk: 
Minimal · up to 42b98
-
The documented Pages Router examples distinguish JSON-only data from the transformer path needed for non-JSON data. No identified issue remains to block merging.
Pre-merge checks: 
5
-
Full details: Docstring Coverage
-
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. 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 0 functions across 3 files.
-
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.
|
@coderabbitai review |
Action performed
|
|
@coderabbitai review |
Action performed
|
@trpc/client
@trpc/next
@trpc/openapi
@trpc/react-query
@trpc/server
@trpc/tanstack-react-query
@trpc/upgrade
commit: |
…-query-based helpers Co-authored-by: alexander <[email protected]>
…ies until the route is ready Co-authored-by: alexander <[email protected]>
3659c51 to
25a13a9
Compare
Keep main's JSDoc descriptions for @trpc/next, with this branch's deprecation notes on the react-query-based APIs. Leave the app-dir exports undeprecated, and point links at setup anchors that still exist. Co-authored-by: alexander <[email protected]>
|
@coderabbitai review |
Action performed
|
|
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. |
Follows #7829, which reverted #7805 and has merged.
Why
@trpc/react-query, which only gets bug fixes and goes away in the next major.@trpc/tanstack-react-queryworks with the Pages Router too, but no page showed how.@trpc/nextas a whole stays: its experimental App Router helpers have no TanStack replacement yet. Only the parts built on@trpc/react-queryare deprecated.What
@trpc/tanstack-react-query. Samples name their query results and use Suspense orswitchonstatus.makeQueryClientfactory,createTRPCContext, andQueryClientProvider,TRPCProviderandHydrationBoundaryin_app. A "Using a data transformer" section runs the whole prefetched cache through superjson, because Next.js page props must be JSON, and query inputs are in the keys, not just the data. ThecreateTRPCNext()options section is replaced by "Moving fromcreateTRPCNext", a table of what replaces each part.getServerSidePropsreplacesssr: true. It builds the context fromcontext.req, verifying the session from the cookie, and sets the status and cache headers oncontext.res(withfetchQueryandnotFoundfor a 404). Calling a separate API server is in a collapsible section.createTRPCOptionsProxy,prefetchQueryanddehydrateinstead ofcreateServerSideHelpers.trpc: { abortOnUnmount: true }on each query, and a note that a batched request only stops once every query in it is cancelled.@deprecatedJSDoc, linking to the replacement, oncreateTRPCNext,withTRPC,ssrPrepass, thessr,ssrPrepassandresponseMetaoptions, and their option types.@trpc/next/app-dir/*exports@deprecated. This PR removes those tags, since nothing replaces those exports yet, and keeps docs(next): document the public API and deprecate it in favor of @trpc/tanstack-react-query #7812's descriptions. JSDoc links to setup anchors this PR removes now point to "Moving fromcreateTRPCNext".@trpc/next's README says the same.httpBatchLinkdrops itscreateTRPCNextsample. The classicuseQuerypage stops linking to the removed setup anchors.Links
_app.tsx: providers andHydrationBoundary.createTRPCNext: new table.getServerSideProps: replacesssr: true.responseMeta.getStaticPropswith superjson.createTRPCOptionsProxy.switchonstatus.Alternatives considered
ssr: trueon top of TanStack. It would bring back a pattern the App Router has replaced, and per-pageprefetchQueryplusdehydrateis only a few lines.@trpc/next. That's on hold until the App Router helpers have a replacement.serializeDatain the query client for the transformer, as the App Router setup does. It only transforms query data, so anundefinedorDatein an input still fails Next.js's props check.Testing
pnpm --filter www typecheck,lintandtest(including the package docs-link check),pnpm format,pnpm validate-skills, the root test suite, and@trpc/next's typecheck and lint pass.next build,next startand a headless browser:getServerSidePropspage and agetStaticPropspage, whose query input has anundefinedfield, render their data into the HTML. The superjsonDatearrives as aDate, the browser sends no tRPC request, and there are no console errors.notFoundreturns a 404, and thecache-controlheader is set.The examples that still use
createTRPCNextaren't moved here.AI model
Claude Opus 5.5
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit
createTRPCNext,withTRPC, and automatic SSR options are deprecated; the legacy integration receives bug fixes only and is planned for removal in the next major version.