Skip to content

Latest commit

聽

History

History

next

README.md

Logto Next.js SDK

Version Build Status Codecov

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.

Installation

Using npm

npm install @logto/next

Using yarn

yarn add @logto/next

Using pnpm

pnpm add @logto/next

Products

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

Request-specific sign-in options

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.

Resources

Website Docs Discord