Composables
useXNeonAuth
Low-level Neon Auth client composable returning structured ok/error results for all auth operations.
useXNeonAuth
Low-level composable that wraps the Neon Auth createAuthClient(). All methods return a structured result object — { status: "ok", data? } on success or { status: "error", error: { message } } on failure — so callers can handle errors explicitly without try/catch. Use useXAuth() for high-level flows with built-in toasts and navigation; use this composable when you need direct control over error handling.
Usage
const {
currentUser,
signInWithCredential,
signUpWithCredential,
signOut,
signInWithOAuth,
sendOtpCode,
verifyOtpCode,
sendMagicLinkEmail,
verifyMagicLink,
sendForgotPasswordEmail,
changePassword,
updateUser,
deleteAccount,
authClient,
} = useXNeonAuth()
Returns
| Key | Type | Description |
|---|---|---|
currentUser() | Promise<{ status, data? }> | Get the current session user. |
signInWithCredential(email, password) | Promise<{ status, data? }> | Sign in with email and password. |
signUpWithCredential(email, password, name?) | Promise<{ status, data? }> | Create a new account, optionally with a display name. |
signOut() | Promise<{ status }> | Sign out the current user. |
signInWithOAuth(provider, options?) | Promise<{ status }> | Initiate OAuth sign-in with the given provider. |
sendOtpCode(email) | Promise<{ status }> | Send an OTP verification code to the given email. |
verifyOtpCode(otp) | Promise<{ status, data? }> | Verify an OTP code. |
sendMagicLinkEmail(email, options?) | Promise<{ status }> | Send a magic link to the given email. |
verifyMagicLink(token) | Promise<{ status, data? }> | Verify a magic link token. |
sendForgotPasswordEmail(email) | Promise<{ status }> | Send a password reset email. |
changePassword(current, new) | Promise<{ status }> | Change the authenticated user's password. |
updateUser({ name?, image? }) | Promise<{ status }> | Update the current user's display name or avatar. |
deleteAccount(password) | Promise<{ status }> | Permanently delete the user's account. |
authClient | object | Raw Neon Auth client instance created via createAuthClient(). |
Error Reference
| Error message | Context |
|---|---|
"No OTP session found" | verifyOtpCode called before sendOtpCode. |
"Invalid credentials" | Wrong email or password in signInWithCredential. |
"Email already exists" | Account already registered in signUpWithCredential. |
"Token expired" | Magic link or password reset token has expired. |
"Incorrect password" | Current password is wrong in changePassword. |
AI Context
composable: useXNeonAuth
package: "@xenterprises/nuxt-x-neon-auth"
use-when: >
When you need raw, structured access to Neon Auth operations without
automatic toasts or navigation — e.g. custom auth flows, server-side
checks, or when you need to inspect the error message directly. Every
method returns { status: "ok" | "error", data?, error? } so you can
branch on status without try/catch. For standard UI auth flows prefer
useXAuth() which layers toasts, loading state, and navigation on top
of this composable.
