This project demonstrates a robust authentication setup in SvelteKit using the better-auth library. It covers login, registration, session management, and secure navigation patterns for modern SvelteKit apps.
This demo uses a simple SQL database for user storage. You can use any SQL database (PostgreSQL, MySQL, SQLite, etc.) that you prefer.
db/schema.sql. Use your preferred SQL database and apply the schema.pnpm run build
src/lib/auth/ — Auth context and helperssrc/lib/client/auth.ts — Client-side auth APIsrc/lib/components/ — UI components (Nav, LogoutButton)src/routes/ — SvelteKit routes (login, register, dashboard)db/schema.sql — Database schemaMIT — free to use, adapt, and ship.
Made with ❤️ with SvelteKit and better-auth