Skip to content
Home / Migrations / ts-resttRPC

ts-rest tRPC

medium

ts-rest gives REST-shaped contracts; tRPC gives RPC. If you don't need REST verbs and are TypeScript-only, tRPC is more ergonomic.

Estimated: 4-8h · 5 steps
Progress0%
Step 1: Install tRPC
npm install @trpc/server @trpc/client @trpc/react-query @tanstack/react-query
Step 2: Recreate routers

ts-rest contract → tRPC router. Each contract endpoint becomes a procedure (publicProcedure.input(z).query/mutation).

Step 3: Migrate auth middleware

ts-rest middleware → tRPC middleware via t.middleware. Attach session/user to ctx.

Step 4: Update client calls

client.endpoint({ body }) → trpc.namespace.endpoint.useQuery(input). Mutations use useMutation().

Step 5: Test types
Server changes propagate to client without rebuilds. No type errors.