The magic of tRPC is making strongly typed API calls without relying on code generation. With full-stack TypeScript projects, you can directly import types from the server into the client! This is a vital part of how tRPC works.
AppRouter type into your client from the file your root tRPC router is defined. This single type represents the type signature of your entire API.
import type keywords let you import from any TypeScript file on your filesystem. Plus
import type can only import types, NOT code. So there's no danger of accidentally importing server-side code into your client. All calls to
Create a typesafe client with the
createTRPCClient method from
As you can see, we passed
AppRouter as a type argument of
createTRPCClient. This returns a strongly typed