Deploy SvelteKit + Better Auth Starter
SvelteKit 3, Better Auth, Postgres/Drizzle, i18n, email: a base to build on
Just deployed
/var/lib/postgresql/data
Just deployed
Deploy and Host a SvelteKit + Better Auth Starter on Railway
A minimal, production-shaped SvelteKit app to build on: sign-in, password reset and email verification (Better Auth), Postgres via Drizzle with migrations, URL-locale i18n (/, /pl, /de, /uk, /es), transactional email, security headers, a health endpoint and one protected area. Source: nomideusz/sveltekit-better-auth-starter.
About Hosting a SvelteKit + Better Auth Starter
Two services: the SvelteKit server (Node adapter, built by Railpack from the repo) and PostgreSQL 17 on a volume. Every deploy runs Drizzle migrations and then creates the admin account from ADMIN_EMAIL / ADMIN_PASSWORD if it does not exist yet, so a fresh deploy has someone who can sign in without opening public sign-up. Sessions, password-reset and verification tokens live in Postgres (Better Auth tables). Email goes out over Resend's HTTP API when RESEND_API_KEY is set (Railway's Hobby plan blocks outbound SMTP ports, so this is the transport that works there) or over SMTP; with neither, reset and verification emails are logged instead of sent and the app runs fully. Built on @sveltejs/kit 3.0.0-next (pre-release) and Svelte 5.
Common Use Cases
- The starting point for a SaaS, internal tool or member area that needs real auth on day one
- A reference for the SvelteKit 3 layout: config in
vite.config.ts, declared env vars,#libimports - Multilingual sites: default locale un-prefixed, others at
//*, one server hook
Dependencies for SvelteKit + Better Auth Starter Hosting
- Bundled: PostgreSQL 17 on a volume
- Optional: a Resend API key (HTTP email — works on the Hobby plan) or SMTP credentials (needs a plan where outbound SMTP is allowed)
Deployment Dependencies
Implementation Details
Sign in at /auth/login with ADMIN_EMAIL and the generated ADMIN_PASSWORD (read it in the service's Variables tab). Change it afterwards via "Forgot your password?" once email is configured (RESEND_API_KEY or SMTP).
Variable wiring:
DATABASE_URL = postgres://${{postgres.POSTGRES_USER}}:${{postgres.POSTGRES_PASSWORD}}@${{postgres.RAILWAY_PRIVATE_DOMAIN}}:5432/${{postgres.POSTGRES_DB}}?sslmode=disable(private network)ORIGIN = https://${{RAILWAY_PUBLIC_DOMAIN}}(auth base URL and email links; change when you attach a custom domain)BETTER_AUTH_SECRETgenerated;ADMIN_PASSWORDgeneratedrailway.tomlin the repo sets the build, pre-deploy (migrate+bootstrap-admin), start command and/api/health
Notes:
- Add your tables to
src/lib/server/db/schema.ts, runpnpm db:generatelocally, commit the migration; it applies on the next deploy. - Public sign-up is off by default; set
ALLOW_SIGNUP=trueto open/auth/signup(new accounts get a verification email). - Upgrade path: fork the repo, point the service at your fork.
Why Deploy a SvelteKit + Better Auth Starter on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying this starter on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Template Content
ADMIN_EMAIL
Your login email - the admin account is created on first deploy
