# @trpc/next

> The tRPC Next.js library

Latest version **11.19.0** (published 2026-09-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @trpc/next
pnpm add @trpc/next
yarn add @trpc/next
bun add @trpc/next
```

Provides the command `intent`.

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; popular repo.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 11.19.0 |
| Published | 2026-09-16 |
| First published | 2021-04-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 196.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 40652 |
| Author | KATT |
| Maintainers | katt, juliusmarminge |
| Keywords | tanstack-intent |

## Links

- npm: https://www.npmjs.com/package/@trpc/next
- Repository: https://github.com/trpc/trpc
- Homepage: https://trpc.io
- Issues: https://github.com/trpc/trpc/issues
- Funding: https://trpc.io/sponsor
- npm.io page: https://npm.io/package/@trpc/next

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 11.19.0 (latest) — 2026-09-16
- 11.19.1-canary.0.sha-8b649ad87 (canary) — 2026-09-17
- 11.13.0 (next) — 2026-03-15
- 10.45.4 (v10) — 2026-01-02
- 11.5.2-alpha-tmp-6955-again.21 (tmp) — 2025-09-25
- 11.5.2-alpha-6955-again-2025-09-24-08-18-00.13 (6955-again) — 2025-09-24
- 10.46.0-alpha-tmp-0202-nosideeffects-main.26 (tmp-main) — 2024-02-02
- 11.18.1-canary.30 — 2026-09-12
- 11.18.1-canary.15 — 2026-09-12
- 11.18.1-canary.9 — 2026-09-12
- 11.18.1-canary.19 — 2026-09-12
- 11.18.1-canary.35.sha-573d4f33e — 2026-09-12
- 11.18.1-canary.34.sha-3a77dc4d6 — 2026-09-12
- 11.18.1-canary.18 — 2026-09-12
- 11.18.1-canary.17 — 2026-09-12
- … 1293 more at https://npm.io/package/@trpc/next/versions

## README

<p align="center">
  <a href="https://trpc.io/"><img src="https://assets.trpc.io/icons/svgs/blue-bg-rounded.svg" alt="tRPC" height="75"/></a>
</p>

<h3 align="center">tRPC</h3>

<p align="center">
  <strong>End-to-end typesafe APIs made easy</strong>
</p>

<p align="center">
  <img src="https://assets.trpc.io/www/v10/v10-dark-landscape.gif" alt="Demo" />
</p>

# `@trpc/next`

> Connect a tRPC router to Next.js.

## Documentation

Full documentation for `@trpc/next` can be found [here](https://trpc.io/docs/client/nextjs)

## Installation

```bash
# npm
npm install @trpc/next @trpc/react-query @tanstack/react-query

# Yarn
yarn add @trpc/next @trpc/react-query @tanstack/react-query

# pnpm
pnpm add @trpc/next @trpc/react-query @tanstack/react-query

# Bun
bun add @trpc/next @trpc/react-query @tanstack/react-query
```

## AI Agents

If you use an AI coding agent, install tRPC skills for better code generation:

```bash
npx @tanstack/intent@latest install
```

## Basic Example

Setup tRPC in `utils/trpc.ts`.

```ts
import { createTRPCNext, httpBatchLink } from '@trpc/next';
// Import the router type from your server file
import type { AppRouter } from '../pages/api/[trpc].ts';

export const trpc = createTRPCNext<AppRouter>({
  config() {
    return {
      links: [
        httpBatchLink({
          url: 'http://localhost:3000/trpc',
        }),
      ],
    };
  },
  ssr: false,
});
```

Hook up tRPC inside `_app.tsx`.

```ts
import { trpc } from '~/utils/trpc';

const App = ({ Component, pageProps }) => {
  return <Component {...pageProps} />;
};

export default trpc.withTRPC(App);
```

Now you can query your API in any component.

```ts
import { trpc } from '~/utils/trpc';

export function Hello() {
  const { data, error, status } = trpc.greeting.useQuery({
    name: 'tRPC',
  });

  if (error) {
    return <p>{error.message}</p>;
  }

  if (status !== 'success') {
    return <p>Loading...</p>;
  }

  return <div>{data && <p>{data.greeting}</p>}</div>;
}
```

## Server components

See https://trpc.io/docs/client/react/server-components

---
_Source: https://npm.io/package/@trpc/next · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
