Summary
Add tRPC as a backend option (or as an add-on layer) for building fully type-safe APIs with no schema or codegen step.
Why
tRPC is the default choice for Next.js + Express stacks where the frontend and backend share a TypeScript monorepo.
It eliminates an entire class of type/contract mismatches between client and server.
Design consideration
tRPC is unusual: it's not a standalone server — it runs on top of an existing HTTP framework (Express, Hono, Next.js API routes).
This means it likely fits better as an add-on (foundation add trpc) rather than a backend replacement.
Discussion on the right category is welcome.
Files to generate
src/trpc/router.ts — root router with example procedure
src/trpc/context.ts — context factory
src/trpc/trpc.ts — initTRPC initialisation
src/trpc/client.ts — typed client (for use in frontend)
- Integration patch into existing:
server.ts (Express middleware mount)
- OR
src/app/api/trpc/[trpc]/route.ts (Next.js App Router adapter)
Implementation hints
Contributor guidance
Refer to CONTRIBUTING.md → "Adding a New Module"
Acceptance criteria
Summary
Add tRPC as a backend option (or as an add-on layer) for building fully type-safe APIs with no schema or codegen step.
Why
tRPC is the default choice for Next.js + Express stacks where the frontend and backend share a TypeScript monorepo.
It eliminates an entire class of type/contract mismatches between client and server.
Design consideration
tRPC is unusual: it's not a standalone server — it runs on top of an existing HTTP framework (Express, Hono, Next.js API routes).
This means it likely fits better as an add-on (
foundation add trpc) rather than abackendreplacement.Discussion on the right category is welcome.
Files to generate
src/trpc/router.ts— root router with example proceduresrc/trpc/context.ts— context factorysrc/trpc/trpc.ts—initTRPCinitialisationsrc/trpc/client.ts— typed client (for use in frontend)server.ts(Express middleware mount)src/app/api/trpc/[trpc]/route.ts(Next.js App Router adapter)Implementation hints
Key dependencies:
@trpc/server@trpc/client@trpc/react-query(if TanStack Query is also selected)compatibility.requires:backend-expressbackend-honofrontend-nextjsWhen both tRPC and TanStack Query are selected:
@trpc/react-querybridge should be wired automaticallyThis is a cross-cutting module:
onBeforeComposehook may be needed to inspect selected backend and inject the correct adapterContributor guidance
Refer to CONTRIBUTING.md → "Adding a New Module"
Acceptance criteria
foundation add trpc(or create-time selection) wires tRPC into the selected backendfrontend-nextjs+ TanStack Query are also selected