Skip to content

Integrating with Next.js

Two SDK options depending on your architecture:

Client-side auth (SPA-style, App Router client components):

Terminal window
npm install @authaction/web-sdk
// app/layout.tsx — wrap with the Next.js provider
import { AuthActionNextProvider } from "@authaction/web-sdk/nextjs";

Server-side sessions (server components, route handlers):

Terminal window
npm install @authaction/server-sdk
app/api/auth/[...authaction]/route.ts
import { createNextHandlers } from "@authaction/server-sdk/nextjs";
export const { GET } = createNextHandlers({ domain, clientId, sessionSecret, redirectUri });
// Handles /api/auth/login, /api/auth/callback, /api/auth/logout automatically

SDK references: web-sdk · server-sdk