@authon/nuxt

Authon Nuxt 3 module — auto-imported composables and middleware
2,931 1
Install
npm install @authon/nuxt
Latest Version:0.9.1
Vue:3
License:MIT
Last Updated:Oct 16, 2026
Links: GitHub  ·  npm
Maintainer: mikusnuz

English | 한국어

@authon/nuxt

Nuxt 3 authentication module with auto-imported composables and Vue components

Requires Node.js ^20.19.0 or >=22.12.0, matching the supported runtime of the current Nuxt release.

Install

npm install @authon/nuxt

Setup

NUXT_PUBLIC_AUTHON_PUBLISHABLE_KEY=pk_test_...
// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@authon/nuxt'],
  runtimeConfig: {
    public: {
      authon: {
        publishableKey: process.env.NUXT_PUBLIC_AUTHON_PUBLISHABLE_KEY,
      },
    },
  },
})

The module installs the runtime plugin and auto-imports useAuthon, useUser, and the Authon Vue components. Do not import the Nuxt module entry from an app page; use the registered components directly:

<script setup lang="ts">
const authon = useAuthon()
const { user } = useUser()
</script>

<template>
  <AuthonSignedOut><button @click="authon.client?.openSignIn()">Sign in</button></AuthonSignedOut>
  <AuthonSignedIn>
    <p>Welcome, {{ user?.displayName }}</p>
    <AuthonUserButton />
  </AuthonSignedIn>
</template>

For explicit imports, use the dedicated entry point:

import { useAuthon, useUser } from '@authon/nuxt/composables'

Configuration

The module also accepts inline options. Keep the publishable key in public runtime config; a server secret, if your own endpoints need one, belongs in private runtime config and is not required by the browser module.

export default defineNuxtConfig({
  modules: ['@authon/nuxt'],
  authon: {
    publishableKey: process.env.NUXT_PUBLIC_AUTHON_PUBLISHABLE_KEY,
    config: { theme: 'auto' },
    globalMiddleware: false,
  },
})

globalMiddleware installs Authon's route middleware globally. Client-side route guards improve navigation UX, but sensitive server/API operations must still verify an access token.

Legacy manual plugin

createAuthonPlugin remains exported for compatibility, but is deprecated for Nuxt applications. Do not create plugins/authon.client.ts in new projects; use modules: ['@authon/nuxt'], auto-imports, and @authon/nuxt/composables instead.

Public API

  • Module: default export, authonModule, AuthonModuleOptions
  • Composables: useAuthon, useUser, useAuthonWeb3, useAuthonPasswordless, useAuthonPasskeys
  • Auto-imported components: AuthonSignIn, AuthonSignUp, AuthonUserButton, AuthonSignedIn, AuthonSignedOut
  • Compatibility helpers: createAuthonPlugin (deprecated), createAuthMiddleware, renderSocialButtons

License

MIT

Related Packages

@roshan-labs/auth

Nuxt auth module

1,300 2
nuxt-define

One utility function for module authors to define compiler constants for all bui...

13,412,511
nuxt-openid-connect

An nuxt 3 module with OpenID-Connect(OIDC) integration.

6,539 42
@lg2/nuxt3-module-create-dato-map

nuxt3-module-create-dato-map

2,869 0
nuxt-csurf

Nuxt Cross-Site Request Forgery (CSRF) Prevention

6,263,746 91

Version History

Version Released Vue License
0.9.1 ^3.0 MIT
0.9.0 ^3.0 MIT
0.8.1 ^3.0 MIT
0.8.0 ^3.0 MIT
0.7.17 ^3.0 MIT