svelte-kit-better-auth-demo Svelte Themes

Svelte Kit Better Auth Demo

SvelteKit Better Auth (Travel Journal)

This repo is a focused, technical demo of integrating Better Auth with SvelteKit. The UI is a simple travel journal, but the real goal is showcasing auth flows, email delivery, and database wiring end-to-end.

What this covers

  • Better Auth + SvelteKit server integration
  • Drizzle adapter with SQLite for persistence
  • Email/password, magic link, and email verification flows
  • Password reset emails
  • Google OAuth (optional)
  • Local email capture via Mailpit (optional)

Local development

  1. Install dependencies:
pnpm install
  1. Configure environment variables:
cp .env.example .env

Update .env with the required values:

DATABASE_URL=local.db
BETTER_AUTH_SECRET=your-random-secret
BETTER_AUTH_URL=http://localhost:5173
MAILER_HOST=127.0.0.1
MAILER_PORT=1036
MAILER_FROM="Travel Journal <[email protected]>"
GOOGLE_CLIENT_ID=your-google-client-id # optional
GOOGLE_AUTH_SECRET=your-google-client-secret # optional
  1. (Optional) Start the local email inbox:
pnpm dev:services

Mailpit runs at http://localhost:8036 and listens for SMTP on port 1036.

  1. Initialize the database:
pnpm db:push
  1. Start the dev server:
pnpm dev

Open http://localhost:5173 in your browser.

Top categories

Loading Svelte Themes