Skip to content

docs: tips that point to query handles, and real types in the App Router setup samples - #7849

Merged
KATT merged 3 commits into
mainfrom
cursor/docs-handles-tips
Nov 3, 2026
Merged

KATT merged 3 commits into
mainfrom
cursor/docs-handles-tips

Conversation

@KATT

@KATT KATT commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Why

  • Readers of the setup and prefetching guides don't learn that handles exist until they reach the handles guide. #7847 rewrites those guides around handles. This PR is the smaller option: the guides keep queryOptions, and a few tips point to handles where a page can start its queries early.
  • The App Router setup's samples typed ~/trpc/server and ~/trpc/client with hand-written declare module stubs. The setup's router makes hello take { text }, but four samples called it with no input, which fails input validation at runtime. The stubs hid that.

What

  • Four :::tip callouts, each linking to Prefetching with handles:
    • TanStack React Query setup, after step 4: start the query in a loader or server component with unstable_$ensure and pass the handle, or use unstable_$prefetch on useTRPC() at the top of the page.
    • Migrating, after "Migrating Queries": once a component is on queryOptions, it can read a handle instead.
    • Pages Router SSR, after the getServerSideProps sample: return a handle instead of the id, so the two inputs can't drift apart.
    • Pages Router server-side helpers, after "Prefetch, fetch and dehydrate": the proxy can return a handle to pass in props.
  • The App Router setup and Server Components pages already had a handles tip, so they get none.
  • Fixes carried over from #7847, without its handles rewrite:
    • App Router setup: the samples in steps 7 and later share one twoslash include built from the setup's real router, query client and server file (prefetch and HydrateClient as on the page). trpc.hello.queryOptions() and caller.hello() now pass { text: 'world' }.
    • Server Components: the useQuery sample switches on greetingQuery.status instead of checking !greeting.data, and the useSuspenseQuery sample names its result greetingQuery instead of destructuring data.
    • Usage: the quick example's component is Greeting, not Users, and renders greetingQuery.data.
    • www/build/collapse.ts: the Shiki transformer is named trpc-docs:collapse, like the others, not raf-query-docs:collapse.
  • Not carried over: anything that turns a sample into a handles sample.

Links

Alternatives considered

  • #7847: every setup guide reads handles. It teaches the new pattern first, but it changes many samples at once while the APIs are still unstable_.
  • A tip on every page that prefetches, such as SSG and the Next.js overview: more tips than readers need. SSR and server-side helpers cover the Pages Router.

Testing

  • pnpm --filter www check-twoslash: 462 blocks compile, including the App Router samples against the real router.
  • pnpm validate-skills: all 24 skills pass, including the size limit on the generated Pages Router skill.
  • pnpm --filter www test (314 tests), pnpm --filter www lint, pnpm typecheck-www and pnpm --filter www build pass. All 698 trpc.io URLs work.
  • In the built HTML, each new tip renders as a callout-tip aside.
  • Handles fit in Pages Router props: a handle is a plain { queryKey, input } object, and since #7848 it leaves out input when it's undefined.

AI model

Claude Opus 5.5

Open in Web Open in Cursor 

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

Summary by CodeRabbit

  • Documentation
    • Expanded guidance for using prefetched query handles with Next.js pages and TanStack React Query, including passing handles to components and reading the associated queries.
    • Clarified how query handles compare with existing prefetching and fetching methods, and when cached data must be available.
    • Updated App Router and React Query examples with consistent inputs and clearer loading, error, and success states.

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

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
www Ready Ready Preview Nov 3, 2026 1:06pm UTC
6 Skipped Deployments
Project Deployment Actions Updated
examples-next-minimal-starter Skipped Skipped Nov 3, 2026 1:06pm UTC
examples-todomvc Skipped Skipped Nov 3, 2026 1:06pm UTC
next-prisma-starter Skipped Skipped Nov 3, 2026 1:06pm UTC
next-prisma-websockets-starter Skipped Skipped Nov 3, 2026 1:06pm UTC
tanstack-start-sse-chat Skipped Skipped Nov 3, 2026 1:06pm UTC
trpc-next-app-dir Skipped Skipped Nov 3, 2026 1:06pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Walkthrough

The v11 client documentation now uses shared App Router setup snippets, consistent query inputs, and query-handle examples. React Query examples show query states and render greeting data. The documentation collapse transformer has a new name.

Changes: Client documentation

Layer / File(s) Summary
App Router examples
www/v11/docs/client/nextjs/app-router-setup.md
Examples use the shared app-router setup snippet. The hello queries and server caller pass { text: 'world' }.
Query-handle guidance
www/v11/docs/client/nextjs/pages-router/server-side-helpers.md, www/v11/docs/client/nextjs/pages-router/ssr.md, www/v11/docs/client/tanstack-react-query/migrating.md, www/v11/docs/client/tanstack-react-query/setup.md
The guides show creating handles with unstable_$ensure and consuming them with unstable_$fromHandle. The setup guide also describes unstable_$prefetch when no loader is available.
React Query examples
www/v11/docs/client/tanstack-react-query/server-components.md, www/v11/docs/client/tanstack-react-query/usage.md
The useQuery example renders pending, error, and success states. The quick example renders greeting data, and the Suspense example reads from greetingQuery.data.

Documentation build

Layer / File(s) Summary
Transformer name
www/build/collapse.ts
The Shiki transformer name changes from raf-query-docs:collapse to trpc-docs:collapse.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Possibly related PRs

  • trpc/trpc#7847: Adds query-handle guidance and examples in the same v11 guides.
  • trpc/trpc#7759: Introduces the query-handle APIs documented in this change.
  • trpc/trpc#7830: Establishes the Pages Router and SSR integration setup used by the handle guidance.

Suggested reviewers: juliusmarminge

Merge Risk: Minimal · up to 22423

The updated guidance clarifies when prefetched data must be transferred to the browser. No actionable merge-blocking risk is identified in this documentation change.

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 accurately summarizes the main changes: documentation tips for query handles and real types in the App Router setup samples.
Docstring Coverage Passed 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. 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: 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 1 files. (1 skipped: 1 unsupported.)

Finishing Touches
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

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between bd8c5bc and 2242311.

Files selected for processing: 1
  • www/v11/docs/client/tanstack-react-query/setup.md
Files skipped from review as they are similar to previous changes: 1
  • www/v11/docs/client/tanstack-react-query/setup.md

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

@pkg-pr-new

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

Copy link
Copy Markdown

Open in StackBlitz

@trpc/client

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

@trpc/next

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

@trpc/openapi

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

@trpc/react-query

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

@trpc/server

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

@trpc/tanstack-react-query

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

@trpc/upgrade

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

commit: 2242311

@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

@vercel
vercel Bot temporarily deployed to Preview – next-prisma-starter November 3, 2026 13:05 Inactive
@vercel
vercel Bot temporarily deployed to Preview – examples-todomvc November 3, 2026 13:05 Inactive
@vercel
vercel Bot temporarily deployed to Preview – trpc-next-app-dir November 3, 2026 13:05 Inactive
@vercel
vercel Bot temporarily deployed to Preview – examples-next-minimal-starter November 3, 2026 13:05 Inactive

@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 on 2242311, and CodeRabbit's one comment is fixed and resolved.

@KATT
KATT added this pull request to the merge queue Nov 3, 2026
Merged via the queue into main with commit 3cf9541 Nov 3, 2026
53 checks passed
@KATT
KATT deleted the cursor/docs-handles-tips branch November 3, 2026 13:20
@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

1 active and 4 inactive deployments
Preview – www — 22423118 Deployed Nov 3, 2026 by vercel[bot]
Preview – examples-next-minimal-starter — 22423118 Deployed Nov 3, 2026 by vercel[bot]
Preview – next-prisma-starter — 22423118 Deployed Nov 3, 2026 by vercel[bot]
Preview – examples-todomvc — 22423118 Deployed Nov 3, 2026 by vercel[bot]
Preview – trpc-next-app-dir — 22423118 Deployed Nov 3, 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