Function: ~~createTRPCNext()~~
On this page
createTRPCNext<
TRouter,TSSRContext>(opts):ProtectedIntersection<CreateTRPCNextBase<TRouter,TSSRContext>,DecorateRouterRecord<TRouter["_def"]["_config"]["$types"],TRouter["_def"]["record"]>>
Defined in: createTRPCNext.tsx:87
Creates typed React hooks and a withTRPC wrapper for a Next.js Pages Router app.
Type Parameters
| Type Parameter | Default type |
|---|---|
TRouter extends AnyRouter | - |
TSSRContext extends NextPageContext | NextPageContext |
Parameters
| Parameter | Type |
|---|---|
opts | WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter> |
Returns
ProtectedIntersection<CreateTRPCNextBase<TRouter, TSSRContext>, DecorateRouterRecord<TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>>
Example
export const trpc = createTRPCNext<AppRouter>({
config() {
return { links: [httpBatchLink({ url: '/api/trpc' })] };
},
});Deprecated
built on @trpc/react-query, which only gets bug fixes. Use
createTRPCContext from @trpc/tanstack-react-query instead.
See
https://trpc.io/docs/client/nextjs/pages-router/setup#moving-from-createtrpcnext