Skip to content

docs(www): query handles blog post: pass the query, not the input - #7773

Open
KATT wants to merge 9 commits into
mainfrom
cursor/query-handles-blog-0ee9
Open

KATT wants to merge 9 commits into
mainfrom
cursor/query-handles-blog-0ee9

Conversation

@KATT

@KATT KATT commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Why

  • Query handles (#7759, #7822, and loadHandles in #7957) need an announcement post.
  • Based on main. The docs it links to, #7817 and #7842, and the demos it uses, #7851, have merged.
  • Most readers use one framework. The post's main flow should work for all of them and stay short, with each framework's details one click away.
  • A reader who picked a framework should be able to share or reload the post and land on the same tab.
  • The post explains timing and data flow, which static ASCII timelines showed poorly. The new website renders React, so the post shows them live, with the demos #7817 builds for the docs.

What

  • New blog post www/blog/query-handles.md (slug query-handles), in the new website's blog format. It explains the problem before the API:
    • Fetch-on-render, with a sample where Comments can't start until PostPage has its post, and a timeline of the waterfall.
    • Render-as-you-fetch: start every query in the loader or server component, then read them in components.
    • The URL is the input: a loader can only start what the route's params and search params name. If a page can't start a query from the URL alone, change the procedure, not the page.
    • Why passing the query beats passing the input: with an input, both sides name the procedure and build the input, so drift (limit: 20 versus limit: 10, a forgotten locale) brings the request back without a word.
    • The API, without a framework: a loader(id) that loads a handle with loadHandles and a prefetchEntry, and a component that reads it with fromHandle(trpc, handle), all from @trpc/tanstack-react-query/unstable-handles. Then how handles work, prefetchEntry / ensureEntry / fetchEntry, mixing them in one load (order doesn't matter, and data has only the waited-for entries), failed entries as a TRPCEntryError, keeping pages waterfall-free, and, for apps without loaders, loading handles in an event handler with useTRPC(), not during render.
    • In your framework: Next.js App Router (a server component page, and the nestable HydrateClient), TanStack Start, and React Router (dehydrate and HydrationBoundary in server loaders), as tabs. The tabs use the site's tab groups (<div class="code-tabs" data-tabs="framework">), so the reader's choice is saved in localStorage and applies to any later page with a framework group. The tabs are links, and the URL keeps the choice, from #7817.
    • Why handles are functions rather than methods on trpc, why the import path says unstable-, and where to go next.
  • The prose follows Orwell's rules: shorter words and sentences, active voice, no stock phrases ("you name it", "That said", "the honest way"). The framework sections moved out of the main flow, so the post reads the same for everyone up to the tabs.
  • Every code block is Twoslash, each with its setup inline and hidden. The blog renderer doesn't expand twoslash include blocks, so the setup can't be shared as it is in the docs. Query results are named (postQuery, commentsQuery) and read through .data, and loader data through loaderData.post.
    • The TanStack Start and React Router route samples check against the real packages: a TanStack Router root route with context, a routeTree.gen.ts registering the router as the generator writes it, and React Router's +types from react-router/internal. Hovering loaderData shows the handle types.
    • Twoslash caught a bug in the render-as-you-fetch fragment: infiniteQueryOptions was missing its getNextPageParam. It now passes it, as the fetch-on-render sample above it does.
  • No comments or discussion settings: the post has no discussion frontmatter. Since #7791, that also means no comments section.
  • The post says the query client dehydrates pending queries, which is what lets the pending ones stream in the Next.js and React Router tabs, and the hidden setups do the same. The TanStack Start tab's loader passes getNextPageParam, as the guides in #7817 do, and getQueryData is shown taking the options' queryKey. The render-as-you-fetch fragment reads its query inside a component, and the TanStack Start tab's router sets up setupRouterSsrQueryIntegration.
  • Following fix(tanstack-react-query): query handles carry no dataΒ #7822, the post says a handle is only { queryKey, input } and the data stays in the cache. "Wait, or don't" says a component that reads a waited-for handle renders the data at once, but still needs a loading state, since the cache can lose the data. A prefetchEntry reader shows a Suspense fallback or useQuery's pending status. The sample that read post.data.title from a handle and the paragraph on a handle's data reaching the browser twice are gone.

Demos

Five demos, all from www/src/demos/ in #7817, placed with demo code fences. Each fence's body is the static stand-in readers see before the demo loads and without JavaScript.

  • Request timeline (twice, for fetch-on-render and render-as-you-fetch) and the URL is the input and the loader diagram: the three demos from the post's first version, now built once and shared with the docs.
  • Since #7851, each request in the demos takes its own time, and the comments take longer than the post. The request timeline's static stand-ins show the same times: post 200 ms, comments 300 ms.
  • Also since docs(www): give each demo query its own time, clickable article cards, and more by the authorΒ #7851, the two live demos open on an article, /posts/1, so the first view already shows the waterfall: the post, its comments and "More by {author}", which starts from the URL with the post. "← All posts" leads to the list, which is one query. The post's intros for both demos match.
  • Start queries in a loader (in "Wait, or don't", new): prefetchEntry, ensureEntry and fetchEntry in a browser loader, and the same blog with no loader, running the real handles API against a tRPC router in the page, with a network panel.
  • Where the queries start (in "Keep it waterfall-free", new): one blog with its queries started in the route loader or in each component, showing the second round trip on each article.

Claude as co-author

  • Claude is listed next to KATT, as the site defines authors in the post's frontmatter: name "Claude", title "Opus 5.5", link https://claude.ai.
  • The avatar is Claude's GitHub avatar (https://github.com/claude.png), the one shown on Claude-co-authored commits. It loads the same way as KATT's, so the post page, the blog index card and the social card show it with no changes outside the post.

Links

Screenshots

Post header Blog index
Post header at 390px, dark: both authors, KATT and Claude Blog index card with both avatars and names Post authors: KATT, Creator of tRPC, and Claude, Opus 5.5

Social card for the post with both authors and their GitHub avatars

After clicking the Next.js tab: the page hasn

Framework tabs Live demos
In your framework: the TanStack Start tab selected Start queries in a loader demo in the post Where the queries start demo at 390px, dark

TanStack Start tab: hovering loaderData shows the handle types

Alternatives considered

  • Keeping the post with the feature or the docs: it made those PRs' diffs larger and tied the post's wording to their review.
  • Leading with the API, as the first draft did: readers who haven't hit the waterfall or the input drift don't see why handles exist.
  • Collapsible sections (<details>) per framework instead of tabs: they work, but each reader opens one and scrolls past the other two closed boxes, and the choice isn't remembered. The site's tab groups already remember the package manager the same way.
  • A framework tab next to every sample: the main flow's samples don't depend on a framework, so only the last section needs tabs.
  • Hosting Claude's avatar in the site's own files: the social card can't fetch site-relative images on previews behind Vercel's login, so it needed extra build plumbing. The GitHub avatar needs none.
  • MDX, to import components into the post: the new site compiles posts as Markdown to HTML at build time, and a fence with a static body keeps the post readable without JavaScript and in feeds.

Testing

  • pnpm --filter www check-twoslash on the post: all 12 blocks pass, and no ts or tsx block is left without Twoslash. A temporary const probe: number = loaderData in both route samples failed with the real loader data type, so neither is any.
  • On a local build, the rendered post contains no hidden setup, and hovering loaderData in the TanStack Start and React Router tabs shows the handle types.
  • pnpm typecheck-www, pnpm --filter www lint, pnpm --filter www test (511 tests) and pnpm --filter www build (all 707 trpc.io URLs resolve) pass.
  • On a local production build, with Playwright in headless Chrome at 1280px light and 390px dark:
    • The post shows both authors, and so does its card on /blog.
    • /og/blog/query-handles.png renders both authors with their avatars (both from GitHub), and the description fits on two lines.
    • Picking TanStack Start in the framework tabs stores it (trpc-docs:tab:framework), and it's still selected after a reload.
    • Framework tabs as links: ?framework=react-router opens on React Router with nothing stored; clicking each tab switches it, sets ?framework=… without a new history entry, and moves the page by 0px; a reload keeps it; the URL wins over the stored choice and the stored choice applies without it; a modifier-click opens ?framework=react-router in a new page on that tab and leaves the current one alone; following a link to /blog drops the param; the quickstart's package-manager tabs are still buttons and leave the URL alone.
    • All five demos load and run, with no console errors and nothing wider than the page.
    • From ?flags=demo#in-your-framework: hovering the TanStack Start tab sets its href to ?flags=demo&framework=tanstack-start#in-your-framework, and Ctrl-click opens that URL in a new page and leaves the current one alone. Space on the focused React Router tab selects it and sets framework=react-router without scrolling the page.
    • With docs(www): give each demo query its own time, clickable article cards, and more by the authorΒ #7851's demos and this post together, the timeline's first run is ready at 500 ms (fetch-on-render), matching the static stand-in, and "Replay with new times" draws new times.
  • The diff against main is the post alone.
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
    • Added a guide to query handles in the TanStack React Query integration, covering prefetching, ensuring and fetching data, typed handles, and infinite queries.
    • Included examples for render-as-you-fetch patterns, client-rendered pages, and integrations with Next.js, TanStack Start, and React Router.
    • Explained pending-query streaming, nested hydration, shared query caches, and the unstable_$ naming.

@vercel

vercel Bot commented Nov 1, 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 8, 2026 6:00pm UTC
examples-todomvc Ready Ready Preview Nov 8, 2026 6:00pm UTC
next-prisma-starter Ready Ready Preview Nov 8, 2026 6:00pm UTC
next-prisma-websockets-starter Ready Ready Preview Nov 8, 2026 6:00pm UTC
og-image Error Error Nov 8, 2026 6:00pm UTC
tanstack-start-sse-chat Ready Ready Preview Nov 8, 2026 6:00pm UTC
trpc-next-app-dir Ready Ready Preview Nov 8, 2026 6:00pm UTC
www Ready Ready Preview Nov 8, 2026 6:00pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
trpc-v12 Ignored Ignored Preview Nov 8, 2026 6:00pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack β†’

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The pull request adds a blog article about query handles. It describes query-starting and handle-reading APIs, URL-based inputs, cache behavior, rendering patterns, and examples for Next.js, TanStack Start, and React Router.

Changes: Query Handles Article

Layer / File(s) Summary
Query handle concepts and framework examples
www/blog/query-handles.md
The article documents query handle APIs, URL-based inputs, cache behavior, render-as-you-fetch patterns, and framework-specific examples. It also covers pending-query dehydration, streaming, and the unstable_$ naming.

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

Change: Other

Possibly related PRs

  • trpc/trpc#7759: Adds the query-handle APIs that the article documents.
  • trpc/trpc#7822: Defines the handle shape and cache relationship described in the article.
  • trpc/trpc#7817: Adds demo rendering and framework tabs used by the article.

Suggested reviewers: nick-lucas

Merge Risk: Minimal Β· previous review 42ae1

The article is ready to merge after normal checks. Its examples now include the hydration prerequisites, correct query-key usage, and valid component hook placement.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the documentation change and states the article’s main topic: query handles that pass queries instead of inputs.
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.
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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between ac8d10b and 42ae1c2.

Files selected for processing: 1

  • www/blog/query-handles.md

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

@KATT
KATT marked this pull request as ready for review November 1, 2026 19:23
@KATT
KATT requested a review from a team as a code owner November 1, 2026 19:23
@cursor cursor Bot changed the title docs(blog): query handles: pass the query, not the input docs(www): query handles blog post: pass the query, not the input Nov 1, 2026
@KATT
KATT added this pull request to stack #7774 November 1, 2026 19:26
@cursor
cursor Bot force-pushed the cursor/query-handles-blog-0ee9 branch from 1d335f6 to 1e90ebd Compare November 1, 2026 19:28
@vercel
vercel Bot temporarily deployed to Preview – next-prisma-starter November 1, 2026 19:28 Inactive
@vercel
vercel Bot temporarily deployed to Preview – trpc-next-app-dir November 1, 2026 19:28 Inactive
@vercel
vercel Bot temporarily deployed to Preview – og-image November 1, 2026 19:28 Inactive
@vercel
vercel Bot temporarily deployed to Preview – examples-todomvc November 1, 2026 19:28 Inactive
@KATT
KATT marked this pull request as draft November 1, 2026 19:29
@KATT
KATT removed this pull request from stack #7774 November 1, 2026 19:30
@pkg-pr-new

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

Copy link
Copy Markdown

Open in StackBlitz

@trpc/client

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

@trpc/next

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

@trpc/openapi

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

@trpc/react-query

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

@trpc/server

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

@trpc/tanstack-react-query

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

@trpc/upgrade

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

commit: c616fd3

@cursor
cursor Bot force-pushed the cursor/query-handles-blog-0ee9 branch from 1e90ebd to c4c65da Compare November 1, 2026 19:33
@vercel
vercel Bot temporarily deployed to Preview – examples-todomvc November 1, 2026 19:34 Inactive
@vercel
vercel Bot temporarily deployed to Preview – next-prisma-starter November 1, 2026 19:34 Inactive
@vercel
vercel Bot temporarily deployed to Preview – trpc-next-app-dir November 1, 2026 19:34 Inactive
@vercel
vercel Bot temporarily deployed to Preview – og-image November 1, 2026 19:34 Inactive
@KATT
KATT added this pull request to stack #7776 November 1, 2026 19:40
@KATT
KATT marked this pull request as ready for review November 1, 2026 19:40
@KATT
KATT removed this pull request from stack #7776 November 1, 2026 19:41
@cursor
cursor Bot force-pushed the cursor/query-handles-blog-0ee9 branch from c4c65da to b70b3f2 Compare November 1, 2026 19:41
@vercel
vercel Bot temporarily deployed to Preview – next-prisma-starter November 1, 2026 19:41 Inactive
@vercel
vercel Bot temporarily deployed to Preview – examples-todomvc November 1, 2026 19:41 Inactive
@vercel
vercel Bot temporarily deployed to Preview – next-prisma-starter November 1, 2026 22:50 Inactive
@cursor
cursor Bot force-pushed the cursor/query-handles-blog-0ee9 branch from 8587340 to 60bae33 Compare November 1, 2026 23:36
@vercel
vercel Bot temporarily deployed to Preview – trpc-next-app-dir November 1, 2026 23:36 Inactive
@vercel
vercel Bot temporarily deployed to Preview – examples-todomvc November 1, 2026 23:36 Inactive
@vercel
vercel Bot temporarily deployed to Preview – next-prisma-starter November 1, 2026 23:36 Inactive

@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 www/blog/query-handles.md Resolved
Comment thread www/blog/query-handles.md Resolved
Comment thread www/build/markdown.ts Resolved
Comment thread www/build/markdown.ts Resolved

@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 www/blog/query-handles.md Resolved
Comment thread www/blog/query-handles.md Resolved
@cursor

cursor Bot commented Nov 2, 2026

Copy link
Copy Markdown

@coderabbitai review

Rebased onto #7817, which now holds the docs, demos and tab links. This PR is the blog post only.

@trpc-bot

trpc-bot commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 3, 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.

KATT and others added 2 commits November 8, 2026 18:55
- Samples import loadHandles, the entries and fromHandle from
  @trpc/tanstack-react-query/unstable-handles.
- "Wait, or don't" mixes entries in one load, shows the typed `data`,
  and how a failed entry rejects with a TRPCEntryError.
- The waterfalls demo moves to "Keep it waterfall-free". "No loader?"
  loads handles in an event handler, not during render.
- "Why unstable_$?" becomes "Why functions" and "Why unstable-".

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch had an error being deployed

1 failed (outdated) and 5 active deployments
Preview – www β€” c616fd3e Deployed Nov 8, 2026 by vercel[bot]
Preview – trpc-next-app-dir β€” c616fd3e Deployed Nov 8, 2026 by vercel[bot]
Preview – next-prisma-starter β€” c616fd3e Deployed Nov 8, 2026 by vercel[bot]
Preview – examples-todomvc β€” c616fd3e Deployed Nov 8, 2026 by vercel[bot]
Preview – examples-next-minimal-starter β€” c616fd3e Deployed Nov 8, 2026 by vercel[bot]
Preview – og-image β€” 4737b0d6 Deployed Nov 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants