A full-stack authentication application built with SvelteKit (Svelte 5), Auth.js, TailwindCSS, PostgreSQL, and Drizzle ORM.
Clone the repository
git clone <repo-url>
cd sveltekit-auth-app
Install dependencies
npm install
Create the database
psql -U postgres -c "CREATE DATABASE sveltekit_auth"
Configure environment variables
cp .env.example .env
Edit .env and fill in:
DATABASE_URL - your PostgreSQL connection stringAUTH_SECRET - generate with openssl rand -hex 32AUTH_GOOGLE_ID / AUTH_GOOGLE_SECRET - from Google Cloud ConsoleAUTH_GITHUB_ID / AUTH_GITHUB_SECRET - from GitHub Developer SettingsPush database schema
npx drizzle-kit push
Alternatively, you can apply the raw SQL schema directly:
psql -U postgres -d sveltekit_auth -f schema.sql
Start the development server
npm run dev
The app will be available at http://localhost:5173.
src/
├── lib/
│ ├── auth.ts # Auth.js configuration
│ ├── index.ts # Lib barrel export
│ ├── assets/
│ │ └── favicon.svg # App favicon
│ ├── components/
│ │ ├── Logo.svelte # Reusable SVG shield logo (AuthKit branding)
│ │ ├── Navbar.svelte # Navigation bar
│ │ └── OAuthButtons.svelte # Google & GitHub sign-in buttons
│ └── server/
│ ├── email.ts # Email sending utility (SMTP)
│ ├── token.ts # Secure token generation
│ └── db/
│ ├── index.ts # Drizzle client
│ └── schema.ts # Database schema
├── routes/
│ ├── +layout.svelte # Root layout with Navbar
│ ├── +layout.server.ts # Session loader
│ ├── +page.svelte # Animated landing page
│ ├── login/ # Login page
│ ├── register/ # Registration page
│ ├── dashboard/ # Protected dashboard
│ ├── profile/ # Protected profile page
│ └── auth/
│ ├── forgot-password/ # Forgot password page
│ ├── reset-password/ # Reset password page
│ └── verify-email/ # Email verification
│ ├── check-email/ # "Check your email" prompt
│ └── resend/ # Resend verification email
├── hooks.server.ts # Auth.js request handler
├── app.css # TailwindCSS + custom animations
├── app.d.ts # TypeScript declarations
└── app.html # HTML template
schema.sql # Raw SQL schema for assignment submission
drizzle.config.ts # Drizzle ORM configuration
The database schema is defined in src/lib/server/db/schema.ts using Drizzle ORM and consists of 4 tables:
| Table | Purpose |
|---|---|
users |
User accounts (id, name, email, hashed password, email verification status) |
accounts |
OAuth provider links (Google, GitHub) tied to users |
sessions |
Active session tokens with expiry |
verification_tokens |
Tokens for email verification and password reset |
A raw SQL version is available in schema.sql at the project root. The schema is applied to PostgreSQL using:
npx drizzle-kit push
npm run dev - Start development servernpm run build - Build for productionnpm run preview - Preview production buildnpm run check - Run svelte-checknpx drizzle-kit push - Push schema changes to databasenpx drizzle-kit studio - Open Drizzle Studio (DB GUI)