npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@logto/nuxt

v2.0.3

Published

[![Version](https://img.shields.io/npm/v/@logto/nuxt)](https://www.npmjs.com/package/@logto/nuxt) [![Build Status](https://github.com/logto-io/js/actions/workflows/main.yml/badge.svg)](https://github.com/logto-io/js/actions/workflows/main.yml)

Readme

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>

Get an access token in the browser

Use the useLogtoAccessToken composable when the browser has to call an API directly, for example an external resource server:

<script setup lang="ts">
const { refresh, error, pending } = useLogtoAccessToken();

const load = async () => {
  const accessToken = await refresh();

  if (!accessToken) {
    // `not_authenticated` means the session cannot be refreshed; start a sign-in instead of
    // retrying.
    await navigateTo('/sign-in');
    return;
  }

  return $fetch('https://api.example.com/profile', {
    headers: { Authorization: `Bearer ${accessToken}` },
  });
};
</script>

Pass resource and organizationId to request a token for a specific API or organization, matching the server-side getAccessToken parameters:

const { refresh } = useLogtoAccessToken({
  resource: 'https://api.example.com',
  organizationId: 'org_123',
});

The composable requests the token from an SDK-managed endpoint, which defaults to /api/logto/access-token and can be changed with the pathnames.accessToken module option.

The refresh always runs on the server against the existing session: a still-valid token is reused, an expired one is exchanged through the refresh token, and the renewed session is written back to the cookies before the response is returned. The refresh token and the app secret never reach the browser.

Notes:

  • refresh() only runs in the browser. During SSR the state stays empty, so no access token is ever serialized into the server-rendered payload. Server-side code should use useLogtoClient() instead, which reads the token straight from the request-scoped client.
  • State is shared between every component using the same resource and organization, and concurrent refresh() calls share a single request.
  • When the session is missing or can no longer be refreshed, the endpoint responds with 401 and the error code not_authenticated, which is available as NotAuthenticatedErrorCode.

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