Customization

Languages and words

English and Spanish built in, any word renamed, and your own languages.

The sign-in pages, the account page, the admin dashboard and the default emails come in English and Spanish:

nuxt.config.ts
export default defineNuxtConfig({
  betterAuthUi: {
    locale: 'es'
  }
})

With @nuxtjs/i18n

When your app uses @nuxtjs/i18n, the pages follow its current language as visitors switch it, when it's one the module has. locale then only sets the default emails' language.

Your own words

messages replaces any of the module's words, per language and key. For example, to call organizations "teams":

nuxt.config.ts
export default defineNuxtConfig({
  betterAuthUi: {
    messages: {
      en: {
        'account.tabs.organizations': 'Teams',
        'signIn.title': 'Log in',
        'errors.USER_NOT_FOUND': 'No such user.'
      }
    }
  }
})

The keys are the module's message keys, in its auth.en.ts and admin.en.ts. The admin's start with admin., and errors are errors.<CODE>.

Adding a language

Give the words for a language, and set it as the locale. English fills in any keys you leave out:

nuxt.config.ts
export default defineNuxtConfig({
  betterAuthUi: {
    messages: {
      fr: {
        'signIn.title': 'Connexion',
        'signIn.submit': 'Se connecter'
      }
    },
    locale: 'fr'
  }
})
For languages the module doesn't have, the default emails and texts stay in English. Write your own templates to send them in yours.

Errors

Better Auth's errors ("Invalid email or password", "Username is already taken", …) are shown in the page's language, by their error code. Codes the module doesn't know show Better Auth's own message. The module's own routes give their errors codes too (USER_NOT_FOUND), so admin messages are translated the same way, and you can reword any of them with errors.<CODE>.

Everything else

  • Numbers and dates, like the home page's chart, follow the page's language.
  • Nuxt UI's own labels, like a password field's "Show password", follow <UApp :locale>, as usual for Nuxt UI. Pass it the same language from @nuxt/ui/locale:
app.vue
<script setup lang="ts">
import { es } from '@nuxt/ui/locale'
</script>

<template>
  <UApp :locale="es">
    <NuxtPage />
  </UApp>
</template>