# Function: ~~withTRPC()~~

> 

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

Defined in: [withTRPC.tsx:162](https://github.com/trpc/trpc/blob/7c907acfd8b31929214792e3b8c2ad7a8ac72563/packages/next/src/withTRPC.tsx#L162)

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 Parameter | Default type |
| ------ | ------ |
| `TRouter` *extends* `AnyRouter` | - |
| `TSSRContext` *extends* `NextPageContext` | `NextPageContext` |

## Parameters

| Parameter | Type |
| ------ | ------ |
| `opts` | [`WithTRPCNoSSROptions`](https://trpc.io/docs/typedoc/next/type-aliases/WithTRPCNoSSROptions.md)\<`TRouter`\> \| [`WithTRPCSSROptions`](https://trpc.io/docs/typedoc/next/type-aliases/WithTRPCSSROptions.md)\<`TRouter`\> |

## Returns

`Function`

### Parameters

| Parameter | Type |
| ------ | ------ |
| `AppOrPage` | `NextComponentType`\<`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
