Configuration
Configuration
app.config.ts
export default defineAppConfig({
xAuth: {
redirects: {
login: '/auth/login',
signup: '/auth/signup',
afterLogin: '/',
afterSignup: '/',
afterLogout: '/auth/login',
forgotPassword: '/auth/forgot-password',
},
features: {
oauth: false,
magicLink: false,
otp: false,
forgotPassword: true,
signup: false,
},
oauthProviders: [],
},
})
Schema Reference
| Key | Type | Default | Description |
|---|---|---|---|
redirects.login | string | '/auth/login' | Path of the login page. |
redirects.signup | string | '/auth/signup' | Path of the signup page. |
redirects.afterLogin | string | '/' | Redirect destination after a successful login. |
redirects.afterSignup | string | '/' | Redirect destination after a successful signup. |
redirects.afterLogout | string | '/auth/login' | Redirect destination after logout. |
redirects.forgotPassword | string | '/auth/forgot-password' | Path of the forgot-password page. |
features.oauth | boolean | false | Enable OAuth/social login buttons. |
features.magicLink | boolean | false | Enable magic link authentication. |
features.otp | boolean | false | Enable OTP (email code) authentication. |
features.forgotPassword | boolean | true | Enable forgot-password flow. |
features.signup | boolean | false | Enable signup page and link. |
oauthProviders | { id, label, icon }[] | [] | OAuth providers shown by XAuthOAuthButtonGroup. Each entry requires id (Stack Auth provider name), label (display text), and icon (Iconify class). |
publicRoutes | string[] | [] | Additional paths the global middleware treats as public (matched by exact path or path prefix). /auth/handler/*, /auth/logout, /terms, and /privacy are always public. |
legal.termsUrl | string | '/terms' | Terms-of-service link shown in the signup form. |
legal.privacyUrl | string | '/privacy' | Privacy-policy link shown in the signup form. |
ui.layout | 'centered' | 'split' | 'centered' | Auth page layout variant. |
ui.background | object | video (Mixkit) | Background for the centered layout: type ('gradient' | 'image' | 'video' | 'solid'), imageUrl, videoUrl, videoCredit, videoCreditUrl, overlayOpacity. Ships with a glassmorphism-over-video default. |
ui.card | object | glass enabled | Card styling: glass (blur effect), glassIntensity ('subtle' | 'medium' | 'strong'), opacity (0–100, ~40 recommended over video). |
ui.split | object | hero left | Split-layout options: heroPosition, heroImageUrl, headline, subheadline, features (string[]). |
ui.showLogo / ui.logoUrl / ui.brandName / ui.tagline | — | logo shown | Branding shown above the auth card. |
ui.form | object | separator shown | icon (Iconify class above the form title) and showSeparator ("or" divider between OAuth buttons and the form). |
See the layer's own app.config.ts for the full ui defaults — override only the keys you need; layer configs deep-merge.
oauthProviders example
oauthProviders: [
{ id: 'google', label: 'Google', icon: 'i-simple-icons-google' },
{ id: 'github', label: 'GitHub', icon: 'i-simple-icons-github' },
]
Runtime Config / Environment Variables
| Variable | Required | Description |
|---|---|---|
NUXT_PUBLIC_STACK_PROJECT_ID | Yes (for auth) | Stack Auth project ID (UUID format). |
NUXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY | Yes (for auth) | Stack Auth publishable client key. |
Missing credentials degrade gracefully.
useXAuthbuilds theStackClientApplazily and guards construction, so without valid credentials nothing throws: public pages render, protected routes still redirect to login, and auth pages show a configuration-warning card instead of a form. Auth methods no-op with error toasts (forgotPasswordkeeps its identical success UX to prevent email enumeration). CheckuseXAuth().isConfiguredin custom components. (Before this fix, the client was constructed eagerly and every page 500'd without valid-format credentials.)
Note the layer's defaults live in app/app.config.ts — Nuxt 4 ignores a layer-level app.config.ts at the package root, and site-overridable ui.* fields ship as undefined (never "") so consumer values always win.
AI Context
package: "@xenterprises/nuxt-x-auth-stack"
config-key: xAuth
use-when: >
Configuring redirect paths, enabling/disabling features (OAuth, magic link,
OTP, forgot password, signup), or listing OAuth providers for nuxt-x-auth-stack.
Set NUXT_PUBLIC_STACK_PROJECT_ID and NUXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY
in environment variables to connect the layer to your Stack Auth project.
