The golden stack: Next.js + tRPC + Drizzle + Zod
Posted by Shyama Sundar · 2026-01-30
Next.js + tRPC + Drizzle + Zod: type errors caught at compile time, end to end. The golden stack emerges — zero runtime type assertions, full type safety from database to UI.
// The golden stack — end-to-end type safety
// schema.ts
const users = pgTable('users', {
id: serial('id').primaryKey(),
name: text('name').notNull(),
email: text('email').notNull().unique(),
});
// router.ts
const appRouter = router({
getUser: publicProcedure
.input(z.object({ id: z.number() }))
.query(async ({ input }) => {
return db.select().from(users).where(eq(users.id, input.id));
}),
});
// component.tsx — fully typed, zero assertions
const { data } = trpc.getUser.useQuery({ id: 1 });
// data is typed as { id: number; name: string; email: string }[]