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.

What this migration involves

Moving from ts-rest to tRPC is rated medium and takes about 4-8h on a typical project. The guide breaks it into 5 steps, 1 of which ship with runnable commands and 1 with a verification check.

FAQ

How long does migrating from ts-rest to tRPC take?

Around 4-8h for a typical project — 5 steps, difficulty rated medium, 1 of them with copy-paste commands.

Is moving from ts-rest to tRPC reversible?

No reverse guide is tracked yet, so treat this as a one-way move and keep a full export of your ts-rest data before you start.

What does tRPC cost compared to ts-rest?

tRPC: open-source from $0/mo, free plan available.