About trpc-tanstack-nextjs
trpc-tanstack-nextjs is a reference skill for building end-to-end type-safe APIs with tRPC v11, TanStack Query, and the Next.js App Router. It covers setup, server and client usage, and optional integrations through focused guides and examples.
Key features
- 01Guides full tRPC setup
- 02Covers routers, procedures, and middleware
- 03Explains client queries and mutations
- 04Covers server prefetching and hydration
- 05Includes optional auth and realtime patterns
Use cases
- 01Setting up type-safe APIs in a Next.js app
- 02Using queries and mutations in client components
- 03Prefetching and hydrating data in server components
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ diegojohnsonl/ trpc-tanstack-nextjs --skill trpc-tanstack-nextjsAfter installing, type/trpc-tanstack-nextjsin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
references/better-auth-integration.mdclient-usage.mdinfinite-queries.mdoptimistic-updates.mdrouters.mdserver-usage.mdsetup.mdsubscriptions.mdDetails
From the project READMEtRPC + TanStack Query + Next.js App Router
End-to-end typesafe APIs for Next.js using tRPC v11 with @trpc/tanstack-react-query adapter.
Core Setup
setup- Full setup from scratch with all modulesrouters- Creating routers, procedures, middlewareclient-usage- Queries, mutations, useUtils in client componentsserver-usage- Prefetching, hydration, getCaller in server components
Optional Integrations
better-auth-integration- Add session/user to tRPC context with Better Authoptimistic-updates- Update UI before server confirmsinfinite-queries- Cursor-based paginationsubscriptions- WebSocket real-time updates
How to Use
Read individual reference files for detailed explanations and code examples:
references/setup.md
references/routers.md
references/client-usage.md
Each reference file contains:
- Code examples with imports
- Usage patterns
- Common variations
Common Gotchas
- Cookies not sent - Add
credentials: "include"to httpBatchLink fetch - Hydration mismatch - Ensure superjson transformer on both client and server
- staleTime: 0 - Causes refetch on every mount; use 30s+ for most cases
- Missing HydrateClient - Prefetched data won't transfer to client
- cache() not used - getCaller/getQueryClient must be wrapped in React cache()
Resources
Comments
Markdown supported