Skip to content

Latest commit

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..

README.md

Logto Nuxt 3 SDK

Version Build Status

The Logto Nuxt 3 SDK written in TypeScript.

Check out our docs for more information.

Installation

Using npm

npm install @logto/nuxt

Using yarn

yarn add @logto/nuxt

Using pnpm

pnpm add @logto/nuxt

Get sample

A sample project can be found at playground.

Check out the full JS repo and try it with pnpm.

pnpm i && pnpm dev

The minimal configuration to run the playground is (use .env file for example):

NUXT_LOGTO_ENDPOINT=<your-logto-endpoint>
NUXT_LOGTO_APP_ID=<your-logto-app-id>
NUXT_LOGTO_APP_SECRET=<your-logto-app-secret>
NUXT_LOGTO_COOKIE_ENCRYPTION_KEY=<random-string>

Request-specific sign-in options

Set module-level signInOptions for defaults shared by every sign-in. To override them for an individual request, register the logto:sign-in-options Nitro hook in a server plugin:

// server/plugins/logto.ts
export default defineNitroPlugin((nitroApp) => {
  nitroApp.hooks.hook('logto:sign-in-options', ({ event, signInOptions }) => {
    const prompt = getQuery(event).prompt;

    if (prompt === 'login' || prompt === 'consent') {
      Object.assign(signInOptions, { prompt });
    }
  });
});

Hook values override module-level defaults. The SDK still owns the callback redirect URI. Validate or allowlist request input before copying it into sign-in options.

Resources

Website Docs Discord