Skip to content

docs(next): document the public API and deprecate it in favor of @trpc/tanstack-react-query - #7812

Merged
KATT merged 3 commits into
cursor/openapi-jsdoc-d5a5from
cursor/next-jsdoc-d5a5
Nov 2, 2026
Merged

KATT merged 3 commits into
cursor/openapi-jsdoc-d5a5from
cursor/next-jsdoc-d5a5

Conversation

@KATT

@KATT KATT commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Why

@trpc/next is deprecated in favor of @trpc/tanstack-react-query. Its JSDoc didn't say so, and most exports had no summary.

What

  • Mark every public export @deprecated: createTRPCNext, withTRPC and its option types, ssrPrepass, and the app-dir/* exports. Each tag reads:
    /**
     * @deprecated Deprecated in favor of `@trpc/tanstack-react-query`.
     * @see https://trpc.io/docs/client/nextjs/app-router-setup
     */
    That page sets up Next.js with @trpc/tanstack-react-query.
  • Short summaries, plus @see links to the Pages Router setup and SSR pages where they exist.
  • No runtime changes and no warnings. No bug-fix-only or next-major claim.

This is stacked on #7809, which adds the link check. It's one of one-PR-per-package.

APIs with no docs page (not invented): experimental_createTRPCNextAppDirClient, experimental_createTRPCNextAppDirServer, experimental_createActionHook, experimental_serverActionLink, experimental_createServerActionHandler, experimental_revalidateEndpoint, experimental_nextCacheLink, experimental_nextHttpLink.

Links

None. No docs pages change.

Alternatives considered

None.

Testing

  • www/build/package-links.test.ts checks every new link against the v11 pages and headings.
  • pnpm test -- --watch false, pnpm typecheck-packages, pnpm lint, pnpm format, pnpm build && pnpm verify-packed pass.
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

  • Documentation
    • Expanded Next.js integration guidance with setup examples and details on client and server usage, query behavior, caching, per-call overrides, and configuration options.
    • Marked existing Next.js integration APIs as deprecated, pointing to @trpc/tanstack-react-query and relevant setup documentation.
    • Clarified server-side query fetching, including that dependent queries may require multiple renders.
    • No runtime behavior or public signatures changed.

@KATT
KATT requested a review from a team as a code owner November 2, 2026 12:37
@vercel

vercel Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
examples-next-minimal-starter Ready Ready Preview Nov 2, 2026 5:11pm UTC
examples-todomvc Ready Ready Preview Nov 2, 2026 5:11pm UTC
next-prisma-starter Ready Ready Preview Nov 2, 2026 5:11pm UTC
next-prisma-websockets-starter Ready Ready Preview Nov 2, 2026 5:11pm UTC
trpc-next-app-dir Ready Ready Preview Nov 2, 2026 5:11pm UTC
www Ready Ready Preview Nov 2, 2026 5:11pm UTC
2 Skipped Deployments
Project Deployment Actions Updated
trpc-v12 Ignored Ignored Preview Nov 2, 2026 5:11pm UTC
tanstack-start-sse-chat Skipped Skipped Nov 2, 2026 5:11pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 04530d5 and 36d4038.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

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 12364e9 and a402182.

Files selected for processing: 1
  • packages/next/src/app-dir/links/nextCache.ts
Files skipped from review as they are similar to previous changes: 1
  • packages/next/src/app-dir/links/nextCache.ts

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

Walkthrough

The PR adds JSDoc to Next.js integration APIs. The documentation describes selected options and behaviors, marks APIs as deprecated, and links to setup or migration guides for @trpc/tanstack-react-query. Runtime behavior and public signatures remain unchanged.

Changes: Next.js integration documentation

Layer / File(s) Summary
App Router API documentation
packages/next/src/app-dir/client.ts, packages/next/src/app-dir/create-action-hook.tsx, packages/next/src/app-dir/links/*, packages/next/src/app-dir/server.ts
Documentation describes client, action, link, and server APIs. It adds deprecation notices and migration links, and documents action error handling and link options.
Pages Router API documentation
packages/next/src/createTRPCNext.tsx, packages/next/src/ssrPrepass.ts, packages/next/src/withTRPC.tsx
Documentation adds setup examples, API descriptions, configuration details, and deprecation notices with links to migration and reference guides.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Other

Possibly related PRs

  • trpc/trpc#7809: Adds the documentation-link checker and updates links. This PR adds JSDoc links checked by that tooling.
  • trpc/trpc#7804: Marks related legacy integrations as deprecated in favor of @trpc/tanstack-react-query.
  • trpc/trpc#7815: Adds analogous public JSDoc and deprecation guidance for @trpc/tanstack-react-query.

Suggested reviewers: nick-lucas

Merge Risk: Low · previous review a4021

Users have a documented Server Actions migration path, but the deprecation wording may still suggest a replacement that the TanStack package does not provide. This is a bounded documentation concern rather than a merge blocker.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: documenting the public @trpc/next API and deprecating it in favor of @trpc/tanstack-react-query. The raw summary confirms that the changes add documentation and @depre…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
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: Title check

Explanation

The title names the main change: documenting the public @trpc/next API and deprecating it in favor of @trpc/tanstack-react-query. The raw summary confirms that the changes add documentation and @deprecated notices across the @trpc/next files, with no runtime changes. The title is specific and matches the changeset, so the check passes.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. 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 1 functions across 8 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.

Share

@cursor

cursor Bot commented Nov 2, 2026

Copy link
Copy Markdown

@coderabbitai review

@trpc-bot

trpc-bot commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • Fix comments: Fix CodeRabbit comments on this PR

Comment thread packages/next/src/app-dir/client.ts Resolved
Comment thread packages/next/src/app-dir/server.ts Resolved
Comment thread packages/next/src/ssrPrepass.ts Resolved
Comment thread packages/next/src/withTRPC.tsx Resolved
Comment thread packages/next/src/withTRPC.tsx Resolved
@pkg-pr-new

pkg-pr-new Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@trpc/client

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

@trpc/next

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

@trpc/openapi

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

@trpc/react-query

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

@trpc/server

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

@trpc/tanstack-react-query

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

@trpc/upgrade

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

commit: 36d4038

@trpc-bot

trpc-bot commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • Fix comments: Fix CodeRabbit comments on this PR

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor
Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

trpc-bot
trpc-bot previously approved these changes Nov 2, 2026

@trpc-bot trpc-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

CI is green and CodeRabbit has no open findings at this head.

@trpc-bot trpc-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Rebased onto main after #7822. CI is green and CodeRabbit has no open findings at this head.

@KATT
KATT added this pull request to the merge queue Nov 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue because a pull request earlier in the stack was removed Nov 2, 2026
@KATT
KATT added this pull request to the merge queue Nov 2, 2026
Merged via the queue into main with commit 1ca5dc8 Nov 2, 2026
52 checks passed
@KATT
KATT deleted the cursor/next-jsdoc-d5a5 branch November 2, 2026 21:21
meefs pushed a commit to meefs/trpc that referenced this pull request Nov 2, 2026
…sources (trpc#7809)

<!-- CURSOR_AGENT_PR_BODY_BEGIN -->
## Why

- The missing-transformer type error said "on your your
`initTRPC`-object".
- Many `trpc.io/docs` links in `packages/*/src` used old paths
(`/docs/v11/...`, `http://`, moved Next.js pages). Nothing caught them.

## What

- Fix the message to match the docs quote: ``You must define a
transformer on your `initTRPC`-object first``. A type test in
`packages/tests/server/transformer.test.ts` asserts the exact text.
- Point every existing docs link in package sources at its current v11
page (16 files).
- Add `www/build/package-links.test.ts`. It runs in CI through `pnpm
--filter www test`. It fails when a `trpc.io/docs` link in
`packages/*/src`:
  - isn't the canonical `https://trpc.io/docs/...` form,
- isn't a v11 docs page (slugs come from the site's own `docPages()`),
or
- has an `#anchor` that isn't a heading on that page (ids come from the
site's own `anchorsOf()`, so `{#id}` overrides count).

This is the base of a stack. The JSDoc work is split into one PR per
package, each based on this branch:

- trpc#7810 `@trpc/server`
- trpc#7814 `@trpc/client`
- trpc#7813 `@trpc/react-query` (deprecated: bug fixes only, removed in the
next major)
- trpc#7815 `@trpc/tanstack-react-query`
- trpc#7812 `@trpc/next` (deprecated in favor of
`@trpc/tanstack-react-query`)
- trpc#7811 `@trpc/openapi` and `@trpc/upgrade`

## Links

None. No docs pages change.

## Alternatives considered

- A script in `scripts/`: it would have to copy the site's slug and
heading-id rules. The www test reuses them, so it matches the built
routes.

## Testing

- `pnpm test -- --watch false`, `pnpm --filter www test`, `pnpm
typecheck-packages`, `pnpm lint`, `pnpm format`, `pnpm build && pnpm
verify-packed` all pass.
- I checked that the link test fails on a bad page and on a bad anchor.

<!-- CURSOR_AGENT_PR_BODY_END -->

<div><a
href="https://cursor.com/agents/bc-582c9e70-feeb-562d-989d-e010a7eed5a5?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
alt="Open in Web" width="114" height="28"
src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a
href="https://cursor.com/background-agent?bcId=bc-582c9e70-feeb-562d-989d-e010a7eed5a5&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
alt="Open in Cursor" width="131" height="28"
src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</div>

<!-- codesmith:footer -->
---
<a
href="https://app.blacksmith.sh/trpc/codesmith/trpc/pr/7809?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=1796215022&installation_model_id=443568&pr_number=7809&ref=codesmith_pr_footer&repository=trpc%2Ftrpc&return_to=https%3A%2F%2Fgithub.com%2Ftrpc%2Ftrpc%2Fpull%2F7809&signature=d5f54bfe70dbaca02e62f8e232c205f9e96577f47476b138ea711f417dad2882"><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 links across client, React, Next.js, TanStack Query, and
server references to current documentation paths and secure HTTPS URLs.
  - Corrected a typo in a transformer-related error message.

- **Tests**
- Added checks for documentation link formats and heading references,
and expanded transformer type coverage.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Cursor Agent <[email protected]>
meefs pushed a commit to meefs/trpc that referenced this pull request Nov 2, 2026
…-query-based helpers (trpc#7830)

<!-- CURSOR_AGENT_PR_BODY_BEGIN -->
Follows [trpc#7829](trpc#7829), which reverted
trpc#7805 and has merged.

## Why

- The Next.js docs still taught `@trpc/react-query`, which only gets bug
fixes and goes away in the next major. `@trpc/tanstack-react-query`
works with the Pages Router too, but no page showed how.
- `@trpc/next` as a whole stays: its experimental App Router helpers
have no TanStack replacement yet. Only the parts built on
`@trpc/react-query` are deprecated.

## What

- Every Next.js page now uses `@trpc/tanstack-react-query`. Samples name
their query results and use Suspense or `switch` on `status`.
- Pages Router setup: a `makeQueryClient` factory, `createTRPCContext`,
and `QueryClientProvider`, `TRPCProvider` and `HydrationBoundary` in
`_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. The `createTRPCNext()`
options section is replaced by "Moving from `createTRPCNext`", a table
of what replaces each part.
- SSR: prefetch per page in `getServerSideProps` replaces `ssr: true`.
It builds the context from `context.req`, verifying the session from the
cookie, and sets the status and cache headers on `context.res` (with
`fetchQuery` and `notFound` for a 404). Calling a separate API server is
in a collapsible section.
- SSG and Server-Side Helpers: `createTRPCOptionsProxy`, `prefetchQuery`
and `dehydrate` instead of `createServerSideHelpers`.
- Aborting: `trpc: { abortOnUnmount: true }` on each query, and a note
that a batched request only stops once every query in it is cancelled.
- App Router setup: two samples fixed for style. The rest already used
TanStack.
- Next.js overview: the Pages Router section and comparison table, plus
a short deprecation note.
- `@deprecated` JSDoc, linking to the replacement, on `createTRPCNext`,
`withTRPC`, `ssrPrepass`, the `ssr`, `ssrPrepass` and `responseMeta`
options, and their option types.
- [trpc#7812](trpc#7812), now on main, also
marked the `@trpc/next/app-dir/*` exports `@deprecated`. This PR removes
those tags, since nothing replaces those exports yet, and keeps trpc#7812's
descriptions. JSDoc links to setup anchors this PR removes now point to
"Moving from `createTRPCNext`".
- `@trpc/next`'s README says the same.
- Outside the Next.js pages: the Response Caching tip is scoped to the
Pages Router (CodeRabbit's note on trpc#7829). The Client overview's Next.js
sentence is updated. `httpBatchLink` drops its `createTRPCNext` sample.
The classic `useQuery` page stops linking to the removed setup anchors.

## Links

- [Pages Router
setup](https://www-git-cursor-next-docs-tanstack-react-query-8095-trpc.vercel.app/docs/client/nextjs/pages-router/setup)
- [6. Configure
`_app.tsx`](https://www-git-cursor-next-docs-tanstack-react-query-8095-trpc.vercel.app/docs/client/nextjs/pages-router/setup#6-configure-_apptsx):
providers and `HydrationBoundary`.
- [Using a data
transformer](https://www-git-cursor-next-docs-tanstack-react-query-8095-trpc.vercel.app/docs/client/nextjs/pages-router/setup#using-a-data-transformer):
superjson for the prefetched cache.
- [Moving from
`createTRPCNext`](https://www-git-cursor-next-docs-tanstack-react-query-8095-trpc.vercel.app/docs/client/nextjs/pages-router/setup#moving-from-createtrpcnext):
new table.
-
[SSR](https://www-git-cursor-next-docs-tanstack-react-query-8095-trpc.vercel.app/docs/client/nextjs/pages-router/ssr)
- [Prefetch in
`getServerSideProps`](https://www-git-cursor-next-docs-tanstack-react-query-8095-trpc.vercel.app/docs/client/nextjs/pages-router/ssr#prefetch-in-getserversideprops):
replaces `ssr: true`.
- [Set the status and cache
headers](https://www-git-cursor-next-docs-tanstack-react-query-8095-trpc.vercel.app/docs/client/nextjs/pages-router/ssr#set-the-status-and-cache-headers):
replaces `responseMeta`.
-
[SSG](https://www-git-cursor-next-docs-tanstack-react-query-8095-trpc.vercel.app/docs/client/nextjs/pages-router/ssg):
`getStaticProps` with superjson.
- [Server-Side
Helpers](https://www-git-cursor-next-docs-tanstack-react-query-8095-trpc.vercel.app/docs/client/nextjs/pages-router/server-side-helpers):
`createTRPCOptionsProxy`.
- [Aborting Procedure
Calls](https://www-git-cursor-next-docs-tanstack-react-query-8095-trpc.vercel.app/docs/client/nextjs/pages-router/aborting-procedure-calls):
per-query option.
- [Next.js
overview](https://www-git-cursor-next-docs-tanstack-react-query-8095-trpc.vercel.app/docs/client/nextjs#pages-router):
Pages Router section and table.
- [App Router
setup](https://www-git-cursor-next-docs-tanstack-react-query-8095-trpc.vercel.app/docs/client/nextjs/app-router-setup#using-data-in-a-client-component):
`switch` on `status`.
- [Response
Caching](https://www-git-cursor-next-docs-tanstack-react-query-8095-trpc.vercel.app/docs/server/caching):
Pages Router tip.

## Alternatives considered

- A helper that brings back `ssr: true` on top of TanStack. It would
bring back a pattern the App Router has replaced, and per-page
`prefetchQuery` plus `dehydrate` is only a few lines.
- Deprecating all of `@trpc/next`. That's on hold until the App Router
helpers have a replacement.
- `serializeData` in the query client for the transformer, as the App
Router setup does. It only transforms query data, so an `undefined` or
`Date` in an input still fails Next.js's props check.

## Testing

- Twoslash compiles every changed sample. `pnpm --filter www typecheck`,
`lint` and `test` (including the package docs-link check), `pnpm
format`, `pnpm validate-skills`, the root test suite, and `@trpc/next`'s
typecheck and lint pass.
- I ran the Pages Router pattern from the final docs in a throwaway
Next.js 15 app (not committed), with `next build`, `next start` and a
headless browser:
  - A plain page fetches in the browser.
- A `getServerSideProps` page and a `getStaticProps` page, whose query
input has an `undefined` field, render their data into the HTML. The
superjson `Date` arrives as a `Date`, the browser sends no tRPC request,
and there are no console errors.
- The context reads the session from the cookie, `notFound` returns a
404, and the `cache-control` header is set.

The examples that still use `createTRPCNext` aren't moved here.

## AI model

Claude Opus 5.5
<!-- CURSOR_AGENT_PR_BODY_END -->

<div><a
href="https://cursor.com/agents/bc-bea99621-3942-5d29-8d59-e21921098095?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
alt="Open in Web" width="114" height="28"
src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a
href="https://cursor.com/background-agent?bcId=bc-bea99621-3942-5d29-8d59-e21921098095&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
alt="Open in Cursor" width="131" height="28"
src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</div>

<!-- codesmith:footer -->
---
<a
href="https://backend.blacksmith.sh/track/enable-autofix?expires=1796234920&installation_model_id=443568&pr_number=7830&ref=codesmith_pr_footer&repository=trpc%2Ftrpc&return_to=https%3A%2F%2Fgithub.com%2Ftrpc%2Ftrpc%2Fpull%2F7830&signature=d40edf48d3ab6e4ece7440c06668fd9c9dc55c1b483bf18cf5a6014cfefcdfe2"><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><a
href="https://app.blacksmith.sh/trpc/codesmith/trpc/pr/7830?autoLogin=true&ref=codesmith_pr_footer">Open
in [code]smith</a> · 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 Next.js guidance to recommend the TanStack React Query
integration for both App Router and Pages Router projects.
* Added deprecation guidance for `createTRPCNext`, `withTRPC`, and
automatic SSR options; experimental App Router helpers remain
unaffected.
* Reworked Pages Router setup, query cancellation, SSR, SSG, and
server-side helper examples around per-page prefetching and cache
hydration.
* Expanded guidance on query cancellation, cache headers, and
prefetch-versus-fetch behavior.
* Improved query examples with explicit loading, error, and success
states.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Cursor Agent <[email protected]>
@github-actions

github-actions Bot commented Nov 4, 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 4, 2026

This branch was successfully deployed

5 active deployments
Preview – www — 36d40385 Deployed Nov 2, 2026 by vercel[bot]
Preview – trpc-next-app-dir — 36d40385 Deployed Nov 2, 2026 by vercel[bot]
Preview – examples-todomvc — 36d40385 Deployed Nov 2, 2026 by vercel[bot]
Preview – examples-next-minimal-starter — 36d40385 Deployed Nov 2, 2026 by vercel[bot]
Preview – next-prisma-starter — 36d40385 Deployed Nov 2, 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