Function: routerType()
On this page
routerType<
TRouter>():RouterType<TRouter>
Defined in: packages/client/src/routerType.ts:29
Passes a router's type to createTRPCClient({ router }) as a normal
option, instead of a type argument. Nothing about the router exists at
runtime, so it's safe to import the router's type only.
Type Parameters
| Type Parameter |
|---|
TRouter extends AnyRouter |
Returns
RouterType<TRouter>
Example
const client = createTRPCClient({
router: routerType<AppRouter>(),
links: [httpBatchLink({ url: 'http://localhost:3000/trpc' })],
});See
https://trpc.io/docs/client/vanilla/setup#3-initialize-the-trpc-client