Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nuxt-alt/auth/llms.txt
Use this file to discover all available pages before exploring further.
@nuxt-alt/auth is written entirely in TypeScript and ships complete type definitions. The module augments three external type namespaces automatically: Nuxt’s NuxtApp (to inject $auth), vue-router’s RouteMeta (to add the auth page meta property), and @nuxt/schema (to add the auth key to NuxtConfig). All of these augmentations are active as soon as the package is installed — no extra configuration is required.
Extending UserInfo
Theauth.user property is typed as UserInfo, a dedicated interface that you can extend via TypeScript declaration merging. This gives you full type safety when reading user properties anywhere in your application.
Create a declaration file (e.g. types/auth.d.ts) in your project root and merge your user shape into the interface:
types/auth.d.ts
auth.user?.email and auth.user?.role will be correctly typed throughout your project. TypeScript will also catch typos like auth.user?.emial at compile time.
The
export {} at the bottom of the file is required to make TypeScript treat the file as a module rather than a global script. Without it, the declare module block may not be recognized correctly.NuxtApp Augmentation
The module augments#app’s NuxtApp interface to add $auth: Auth. This means $auth is available everywhere useNuxtApp() is used without any additional type imports:
Auth instance with identical type information.
RouteMeta Augmentation
The module augmentsvue-router’s RouteMeta interface to add the auth property. This means definePageMeta will surface TypeScript errors if you pass an invalid value:
auth: true is not a valid value. To require authentication on a page, simply leave the auth property unset. When globalMiddleware is true, all pages without an explicit auth value are treated as protected. To opt a page out of auth entirely, set auth: false.ModuleOptions Type
You can import theModuleOptions type directly from @nuxt-alt/auth when you want to build a typed configuration object outside of nuxt.config.ts:
ModuleOptions is also re-exported from the main package entry point, so it is always available without digging into sub-paths.
Scheme Type Narrowing
TheAuth class provides three typed strategy getters that all return the same active strategy at runtime but expose different TypeScript types. This lets you safely access token-specific APIs without unsafe casts:
SchemeCheck return type from auth.check() is also fully typed:
Module Aliases
The module registers three path aliases that you can use when building custom schemes or providers. TypeScript will resolve these correctly through Nuxt’s tsconfig path mapping:#auth/runtime
Access the core
Auth class, Storage, token helpers, and middleware directly.#auth/providers
Import built-in provider configurations such as
github, google, and laravelSanctum.#auth/utils
Access shared utilities like
routeMeta, normalizePath, isSet, and getProp.