Docs

Email and password

Sign users up, confirm their email, sign them in, and let them reset a forgotten password.

Updated Nov 25, 2026

#Sign up

const sovaria = createClient('https://<project-ref>.sovarias.in', '<anon-key>')

const result = await sovaria.auth.signUp('ada@example.com', 'Correct-Horse-9!', 'Ada')
if (result.email_verification_required) {
  showMessage('Check your inbox to confirm your email.')
} // otherwise the user is signed in
  • Sign-ups must be allowed for the project (Sign in / Providers → Allow new users to sign up); otherwise the API answers 403.
  • Default password rules: at least 8 characters with an uppercase letter, a digit and a symbol. Change them under Security & JWT. A weak password returns 422 with the rule it broke.
  • signUp creates the user and signs them in. register only creates the user. Without a name, the part of the email before the @ is used.
  • An address that already has an account: sign-up answers exactly like a new one (same 201, same fields, same time), creates nothing and starts no session, so nobody can use your sign-up form to find out who has an account. The owner of the address gets an email saying someone tried to sign up, with a sign-in link and a one-time password-reset link (at most one an hour). signUp then signs in with the password given, which only succeeds if it is that account's own password; otherwise it fails like any wrong password. With email confirmation on, the answer also says email_verification_required: true, as for a new account.

supabase-js-style calls work too, and never throw: the error comes back in error. options.data is saved as the user's user_metadata when the account is created, also while the email waits to be confirmed (over HTTP: data in the sign-up body).

const { data, error } = await sovaria.auth.signUp({
  email: 'ada@example.com',
  password: 'Correct-Horse-9!',
  options: { data: { full_name: 'Ada Lovelace' } },   // full_name / name also becomes the display name
})
if (error) showError(error.message)
else if (!data.session) showMessage('Check your inbox to confirm your email.')

#Confirm the email address

URL configuration pageURL configuration page
URL configuration: the Site URL your email links open, and other redirect URLs you allow (* matches one subdomain label or path segment, ** any path below; app schemes like myapp://callback work too). Wildcards are for subdomains and paths of a domain you own: ** is refused in the host and so is a wildcard in the domain itself (https://**, https://*.com, https://example.*), because a sign-in code or email link sent there would reach whoever owns that host. The same goes for a wildcard over a shared hosting domain (https://*.vercel.app, https://*.github.io, https://*.co.uk): name your own subdomain (https://*.yourapp.com). A redirect URL may use up to 4 wildcards, at most 2 in its path; one saved with more no longer matches. A URL with credentials (user@host) or a backslash never matches, and neither does a redirect_to longer than 2,048 characters.

When email verification is on, the user receives a confirmation email. The link opens your Site URL with ?token=…&type=signup. Call handleEmailLink() on that page:

const result = await sovaria.auth.handleEmailLink()   // reads window.location
if (result?.type === 'signup') showMessage('Email confirmed — you can sign in now.')

Someone else may have registered the address first. Confirming from the account's own session (the SDK sends it when the user is signed in, for example an anonymous user who just added their email) only confirms it. Confirming from anywhere else — another device, the mail app's browser, no session — also confirms it and signs nobody out, but the account is marked: the inbox owner's first sign-in that proves the inbox (a magic link or email code, a password reset, or Google/GitHub/SSO with a verified email) ends everything set before the address was proven — the password, phone, two-factor methods, passkeys, linked identities and sessions — so a person who registered someone else's address can't keep a way in.

#Sign in

const session = await sovaria.auth.signIn('ada@example.com', 'Correct-Horse-9!')
if (session.mfa_required) {
  // ask for the 6-digit code from their authenticator app
  await sovaria.auth.verifyMfa(code)
}
const me = await sovaria.auth.me()

Or, as in supabase-js (data.mfa_required means call verifyMfa(code) next):

const { data, error } = await sovaria.auth.signInWithPassword({ email, password })
if (error) showError(error.message)          // e.g. wrong password: error.statusCode === 401
else setUser(data.user)                       // { id, email, user_metadata, app_metadata, is_anonymous, … }

Wrong credentials return 401 with a generic message. Repeated failures are rate-limited per IP and per email.

#The user and their metadata

getUser() (GET /api/v1/auth/me) reads the signed-in user from the server, with their user_metadata, app_metadata and is_anonymous. updateUser() (PATCH /api/v1/auth/me) changes what the user may change about themselves: data is merged into user_metadata (a null value removes a key), a new email is confirmed by a link first, and a new password needs the current one (or a nonce from a recent sign-in). An anonymous user who adds an email becomes a permanent one. app_metadata is for your admins only (Users and app roles).

const { data: { user } } = await sovaria.auth.getUser()       // null when nobody is signed in
const { error } = await sovaria.auth.updateUser({ data: { theme: 'dark' } })
await sovaria.auth.updateUser({ password: newPassword, currentPassword })

#Reset a forgotten password

  1. Request the email

    await sovaria.auth.resetPasswordForEmail('ada@example.com', { redirectTo: 'https://app.example.com/reset' })
  2. Handle the link

    The link opens redirectTo (or your Site URL) with ?token=…&type=recovery. handleEmailLink() returns the token so you can show a "new password" form.

  3. Set the new password

    const link = await sovaria.auth.handleEmailLink()
    if (link?.type === 'recovery') {
      await sovaria.auth.confirmPasswordReset(link.token, newPassword)
    }

#Coming from Firebase or Supabase?

PlatformWhat this is called there
FirebaseFirebase email/password sign-in
SupabaseSupabase email and password login
SovariaEmail and password

Moving an existing app? Migrate from Supabase or Firebase imports users (with their passwords), data, files and rules.