Skip to content
tRPC

Partners

Function: ~~withTRPC()~~

On this page

withTRPC<TRouter, TSSRContext>(opts): (AppOrPage) => NextComponentType

Defined in: withTRPC.tsx:162

Wraps a Next.js app or page with the tRPC and TanStack Query providers. createTRPCNext returns it, and you wrap your app with it: export default trpc.withTRPC(MyApp).

Type Parameters

Type ParameterDefault type
TRouter extends AnyRouter-
TSSRContext extends NextPageContextNextPageContext

Parameters

ParameterType
optsWithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>

Returns

Function

Parameters

ParameterType
AppOrPageNextComponentType<any, any, any>

Returns

NextComponentType

Deprecated

built on @trpc/react-query, which only gets bug fixes. Mount TRPCProvider from @trpc/tanstack-react-query in _app instead.

See

https://trpc.io/docs/client/nextjs/pages-router/setup#moving-from-createtrpcnext