Skip to content
tRPC

Partners

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 ParameterDefault type
TRouter extends AnyRouter-
TSSRContext extends NextPageContextNextPageContext

Parameters

ParameterType
optsWithTRPCNoSSROptions<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