Next.js SDK
App Router adapter with server-side OAuth and encrypted cookie sessions.
@wocha/nextjs is the Next.js App Router adapter for Wocha. It implements a BFF (backend-for-frontend) pattern: OAuth runs server-side with a confidential client, and sessions are stored in encrypted HTTP-only cookies.
Installation
pnpm add @wocha/nextjsOr scaffold with the CLI
npx @wocha/cli init --framework nextjsPeer dependencies: Next.js 14+, React 18+.
Environment variables
Route handler
When env vars are set, you can omit the config object:
Middleware
Expired access tokens are refreshed silently using the refresh token before redirecting to login.
Server helpers
Use server-side helpers in Server Components and route handlers:
Client hooks
Wrap your layout with WochaSessionProvider and use client hooks:
Learn more
- Next.js quickstart
- React SDK — for SPAs without a server BFF