Function: createTRPCClient()
On this page
createTRPCClient<
TRouter>(opts):TRPCClient<TRouter>
Defined in: packages/client/dist/index.d.mts:245
Creates a typed client for a router. Pass the router's type, and the links that send its calls.
Type Parameters
| Type Parameter |
|---|
TRouter extends AnyRouter |
Parameters
| Parameter | Type |
|---|---|
opts | CreateTRPCClientOptions<TRouter> |
Returns
TRPCClient<TRouter>
Example
const client = createTRPCClient<AppRouter>({
links: [httpBatchLink({ url: 'http://localhost:3000/trpc' })],
});
const post = await client.post.byId.query({ id: '1' });See
https://trpc.io/docs/client/vanilla/setup#3-initialize-the-trpc-client