Skip to content

Auth add-on

Auth, built into your database

Turn any of your SQL databases into your auth server with Better Auth: libSQL, Postgres, MySQL, MariaDB, or SQLite, scaffolded in one click. Email and password sign-in, plus OAuth with Google and GitHub, on a database you own. No separate auth service, no extra bill.

The user-management console covers libSQL, Postgres, MySQL, and MariaDB. SQLite is scaffold and recipes only, no console.

One-click schema

Toggle "Set up as Auth Server", then apply the Better Auth tables in one click from the dashboard, or run your own migration. Your call, no black box.

Email and password, day one

Better Auth handles password hashing (scrypt), sessions, and email verification. Optionally seed an admin user at create time and sign in immediately.

OAuth and OIDC-ready

The setup wizard scaffolds Google and GitHub sign-in with the redirect URLs and env vars filled in. Better Auth supports many more providers when you need them.

Bring your own library

Prefer Auth.js? Copy-paste recipes for Drizzle, Kysely, and Prisma ship in the dashboard, plus raw client and Python recipes.

Quickstart

Point Better Auth at your Layerbase database. Pick your engine:

ts
import { betterAuth } from 'better-auth'
import { createClient } from '@libsql/client'
import { LibsqlDialect } from '@libsql/kysely-libsql'

export const auth = betterAuth({
  database: {
    dialect: new LibsqlDialect({
      client: createClient({
        url: process.env.LIBSQL_URL!,
        authToken: process.env.LIBSQL_AUTH_TOKEN,
      }),
    }),
    type: 'sqlite',
  },
  emailAndPassword: { enabled: true },
})

Common questions

Do I have to run migrations?

Only if you want to. Creating the database with the Auth Server preset sets it up for the Better Auth schema (user, session, account, verification); apply it in one click from the Setup panel on libSQL, Postgres, MySQL, or MariaDB, or run your own migration with the Better Auth CLI or your ORM. On SQLite you apply the generated SQL yourself. Other libraries (Auth.js, raw clients) manage their own schema and are best on a fresh database.

Which engines get the user console?

The user-management console (list, create, reset password, ban, delete) works on libSQL, Postgres, MySQL, and MariaDB. SQLite is scaffold and recipes only: you apply the schema and manage rows yourself, since there is no server-side runner for the embedded engine.

Is it free?

libSQL, Postgres, MariaDB, and SQLite are on the Layerbase free tier, including TLS, generated credentials, and IP allowlists, with no separate charge for auth. MySQL starts on the Solo plan. Either way there is no separate auth bill.

Does it work outside Next.js?

Yes. Better Auth is framework agnostic, so the same setup works behind Express, Hono, SvelteKit, Remix, or plain Node. The dashboard also ships raw client and Python recipes.

Further reading:Setup guideBetter Auth: email and password