Sign In

@authon/nuxt

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@authon/nuxt

Authon Nuxt 3 module — auto-imported composables and middleware

Source
npmnpm
Version
0.1.15
Version published
Weekly downloads
29
-19.44%
Maintainers
1
Weekly downloads
 
Created
Source

@authon/nuxt

Nuxt 3 module for Authon — auto-imported composables, components, and server middleware.

Install

npm install @authon/nuxt
# or
pnpm add @authon/nuxt

Requires nuxt >= 3.0.0.

Quick Start

1. Add Module

// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@authon/nuxt'],
  authon: {
    publishableKey: process.env.NUXT_PUBLIC_AUTHON_KEY,
  },
});

2. Use in Pages

All composables and components are auto-imported:

<!-- pages/index.vue -->
<template>
  <div>
    <SignedIn>
      <UserButton />
      <p>Welcome, {{ user?.displayName }}</p>
    </SignedIn>
    <SignedOut>
      <button @click="openSignIn()">Sign In</button>
    </SignedOut>
  </div>
</template>

<script setup>
const { user, openSignIn } = useAuthon();
</script>

3. Server-side

// server/api/profile.get.ts
export default defineEventHandler(async (event) => {
  const user = await requireAuthonUser(event);
  return { user };
});

API Reference

Module Options

// nuxt.config.ts
authon: {
  publishableKey: string;
  secretKey?: string;        // For server-side verification
  apiUrl?: string;
  publicRoutes?: string[];   // Routes that don't require auth
}

Auto-imported Composables

ComposableDescription
useAuthon()Full auth state and actions
useUser()Current user and loading state

Auto-imported Components

ComponentDescription
<SignedIn>Renders slot only when signed in
<SignedOut>Renders slot only when signed out
<UserButton>Avatar dropdown with sign-out
<Protect>Conditional rendering with fallback slot

Server Utilities

FunctionDescription
requireAuthonUser(event)Get and verify the current user (throws 401 if unauthenticated)
getAuthonUser(event)Get the current user or null

Documentation

authon.dev/docs

License

MIT

Keywords

authon

FAQs

Package last updated on 23 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts