The Logto Next.js SDK written in TypeScript.
Check out our docs for more information.
If you are using App Router and Server Actions, check out the docs for more information.
npm install @logto/nextyarn add @logto/nextpnpm add @logto/next| Name | Description |
|---|---|
| @logto/next | Traditional Next.js SDK using Page Router |
| @logto/edge | Next.js SDK running in edge environment |
| @logto/server-actions | Next.js SDK for App Router and Server Actions |
The Pages Router combined auth handler accepts shared defaults and a resolver for individual requests:
import { Prompt } from '@logto/next';
export default logtoClient.handleAuthRoutes({
signInOptions: { prompt: Prompt.Login },
getSignInOptions: (request) => {
const prompt = request.query.prompt;
return prompt === 'consent' ? { prompt: Prompt.Consent } : {};
},
});Resolver values override signInOptions. The SDK manages callback redirect fields and forces the
registration screen for the sign-up route. Validate or allowlist request input before copying it
into sign-in options.