Deploying tRPC type changes without breaking the frontend
Inferred tRPC types are convenient until server and client deploy separately. Here is how to catch contract breaks in CI.
07 Mar 2026, 21:51 UTC

The problem: a type-safe call that fails at runtime
You add a required field to a tRPC procedure input, update the React form, and run tsc --noEmit locally. Everything passes. You deploy the server first. The next time the client mounts, useQuery sends the old payload, the server rejects it, and the user sees an error screen. TypeScript did not catch it because the client was type-checked against the old server output.
tRPC infers input and output types from Zod schemas (a TypeScript validation library) and procedure definitions, so there is no separate contract file or codegen step. That convenience becomes a deployment risk when the server and client are not released at the same moment.
What breaks and why
tRPC procedures resolve over HTTP POST by default. The client builds the request body from the inferred TypeScript type. If the server schema changes to require a new field, the client still compiles because its local copy of the type has not updated yet. The mismatch only appears over the network.
Plain thrown errors also surface as INTERNAL_SERVER_ERROR unless you throw TRPCError from @trpc/server, so a validation failure can look like a generic server crash instead of a contract problem.
Worked example: shared types and a CI check
Put shared types in a package both sides import, then verify alignment in continuous integration before either service deploys.
# Run from the monorepo root as a normal user; no sudo required
cd packages/shared
cat > index.ts <<'EOF'
export type GetUserOutput = { id: string; email: string; }
EOFServer side:
import { initTRPC } from '@trpc/server';
import { z } from 'zod';
import type { GetUserOutput } from '@repo/shared';
const t = initTRPC.create();
export const appRouter = t.router({
getUser: t.procedure
.input(z.string().uuid())
.query(async ({ input }) => {
const user = await db.user.findUnique({ where: { id: input } });
if (!user) {
throw new Error('not found');
}
return user as GetUserOutput;
}),
});Client side:
import { createTRPCReact } from '@trpc/react-query';
import type { AppRouter } from '@repo/server';
export const trpc = createTRPCReact<AppRouter>();
// In a component
const { data } = trpc.getUser.useQuery('550e8400-e29b-41d4-a716-446655440000');
// data is inferred as GetUserOutput; no explicit generic on useQueryCI check:
# Run in CI after merging, before deploying server or client
tsc --noEmit -p apps/server/tsconfig.json
tsc --noEmit -p apps/web/tsconfig.jsonExpected result: both commands exit with code 0. If the server schema changed and the client still imports the old type, the client check fails and blocks deployment.
Limitation: types are not versioned
tRPC does not publish an OpenAPI or GraphQL schema, and there is no built-in procedure versioning. Changing an input or output type is a breaking change until every client consuming that router redeploys. You cannot safely remove a field or make an optional field required without coordinating deploy order or keeping the old procedure alongside the new one.
Practical check: after modifying a router, run tsc --noEmit in the client workspace. If it passes, the inferred types still align. If it fails, update the client before deploying the server, or add a new procedure instead of changing the existing one.
Closing
Use a shared types package so server and client import the same declarations, run tsc --noEmit across both workspaces in CI, and throw TRPCError for validation failures so clients can distinguish contract errors from server crashes. Until you have that gate, treat every tRPC procedure change as a coordinated release, not a local type edit.