tRPC × Next.js App RouterSource
Experimental

tRPC in the Next.js App Router

Server Components, Server Actions and React Query with tRPC's experimental App Router APIs. Each page shows one way to use them.

Session
Sign in to see authenticated procedures like secret on the Server Components page.

Showcase pages

Server functions with only @trpc/server, and no other @trpc/* packages

Prefetch in a Server Component, then read and invalidate the query on the client

Call procedures from Server Components, cache them, and revalidate the cache

Fetch from a Client Component

Procedures as Server Actions, with useAction and forms

Read in a Server Component, write with a Server Action, then revalidate