Railway

Deploy SvelteKit + Better Auth Starter

SvelteKit 3, Better Auth, Postgres/Drizzle, i18n, email: a base to build on

Deploy SvelteKit + Better Auth Starter

/var/lib/postgresql/data

Deploy and Host a SvelteKit + Better Auth Starter on Railway

Deploy 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, #lib imports
  • 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_SECRET generated; ADMIN_PASSWORD generated
  • railway.toml in 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, run pnpm db:generate locally, commit the migration; it applies on the next deploy.
  • Public sign-up is off by default; set ALLOW_SIGNUP=true to 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

More templates in this category

View Template
open-excalidraw
Self-hostable collaborative drawing built on Excalidraw

Prateek Mohanty
1
View Template
caring-vibrancy
Deploy and Host caring-vibrancy with Railway

5
View Template
Appsmith
Low-code platform for internal tools, dashboards, and admin panels.

Agaz Self-Host
0