Skip to content

tRPC + Next 13 app directory + TypeScript + (prisma?)

Notifications You must be signed in to change notification settings

mehdinourollah/trpc-next13-app

 
 

Repository files navigation

This is a small proof-of-concept showing how to get tRPC working with the Next 13 app directory, all in TypeScript. All of the code is drawn from the tRPC tutorial, here, and here. Some attempt has been made to minimize the example code.

Note this code contains only an example of performing an RPC from a Client Component. I am not sure how to get tRPC calls working from a React Server Component, tbh, but it seems like this is an area of active investigation.

Running

First, run the development server:

npm run dev
# or
yarn dev
# or
pnpm dev

Open http://localhost:3000 with your browser to see the result. A simple page displays the result of a tRPC call. You can edit MyRpcClientComponent.tsx to change the query being made, or trpc-server.ts to change the "API" and see that the client and server both fail to compile.

Recreating

npx create-next-app@latest --experimental-app trpc-next
cd trpc-next/
npm install @trpc/client @trpc/react-query @tanstack/react-query @trpc/server zod

This should be the basics needed if you want to incorporate this into an existing project.

About

tRPC + Next 13 app directory + TypeScript + (prisma?)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 96.4%
  • JavaScript 3.6%