--- name: install-next description: >- Installs and wires @rsc-boundary/next into a Next.js App Router app (dependencies, root layout provider, optional explicit markers). Use when the user wants to add RSC Boundary, integrate @rsc-boundary/next, or set up server/client boundary devtools in Next.js. The unscoped rsc-boundary package on npm is deprecated — see migration note. --- # Install RSC Boundary in a Next.js app **Package:** `@rsc-boundary/next` on npm. The unscoped `rsc-boundary` package on npm is **deprecated** — for new projects always install `@rsc-boundary/next` (it pulls in `@rsc-boundary/core` automatically). ## Prerequisites - **Next.js** 16+ with the **App Router** - **React** 19+ and **react-dom** 19+ (peer dependencies) If versions are older, say so and recommend upgrading before installing. ## 1. Install the dependency Use the project's package manager: ```bash pnpm add @rsc-boundary/next ``` ```bash npm install @rsc-boundary/next ``` ```bash yarn add @rsc-boundary/next ``` ### Migrating from `rsc-boundary` If the user still has the deprecated unscoped `rsc-boundary` package installed, the migration is a one-liner: ```bash pnpm remove rsc-boundary && pnpm add @rsc-boundary/next ``` Then replace the import everywhere (one global find-and-replace): ```diff -import { ... } from "rsc-boundary"; +import { ... } from "@rsc-boundary/next"; ``` The API surface is identical — no other code changes are needed. ### Monorepo / local development If the user is working inside this repository and consuming the package from the workspace, use the workspace protocol: ```json "@rsc-boundary/next": "workspace:*" ``` Ensure the packages are built (`pnpm --filter @rsc-boundary/next build`, which also builds core) before the app typechecks against `dist/`. ## 2. Wrap the App Router root layout Edit **`app/layout.tsx`** (or the file that exports the root `RootLayout` for `app/`). 1. Import the provider: ```tsx import { RscBoundaryProvider } from "@rsc-boundary/next"; ``` 2. Wrap `{children}` (inside `
`) with `