Documentation
Quick Start
Project Structure
src/ ├── lib/server/ │ ├── auth/ Auth.js config (Google + Email) │ ├── db/ Drizzle schema + connection │ ├── email/ Resend templates │ └── stripe/ Checkout, portal, webhooks ├── routes/ │ ├── +page.svelte Landing page │ ├── login/ Sign-in (OAuth + magic link) │ ├── dashboard/ Auth-gated main app │ ├── settings/ Profile + billing │ ├── admin/ Role-gated admin panel │ └── api/ │ ├── billing/ Checkout + portal endpoints │ └── webhooks/stripe/ Webhook handler ├── app.css Tailwind styles ├── app.html HTML shell └── hooks.server.ts Auth middleware
Environment Variables
Database
DATABASE_URL PostgreSQL connection stringAuthentication
AUTH_SECRET Random string for session encryptionAUTH_GOOGLE_ID Google OAuth client IDAUTH_GOOGLE_SECRET Google OAuth client secretStripe
STRIPE_SECRET_KEY Stripe secret API keySTRIPE_WEBHOOK_SECRET Webhook signing secret (whsec_...)STRIPE_PRICE_MONTHLY Price ID for monthly subscriptionRESEND_API_KEY Resend API key for sending emailApp
PUBLIC_APP_URL Your app URL (e.g. https://myapp.com)Authentication Setup
Google OAuth: Create credentials at console.cloud.google.com. Add http://localhost:5173/auth/callback/google as an authorized redirect URI.
Magic Link Email: Get a Resend API key at resend.com. Verify your sending domain. The template sends styled verification emails automatically.
Adding Providers: Auth.js supports 80+ providers. Add any provider by installing its package and adding it to src/lib/server/auth/index.ts.
Stripe Billing Setup
1. Create a product in the Stripe dashboard with a recurring price. Copy the price ID to STRIPE_PRICE_MONTHLY.
2. Set up webhooks — add an endpoint pointing to https://yourdomain.com/api/webhooks/stripe. Listen for: checkout.session.completed, customer.subscription.updated, customer.subscription.deleted.
3. Test locally with stripe listen --forward-to localhost:5173/api/webhooks/stripe.
Deployment
Works with any platform that runs Docker: Railway, Fly.io, Render, AWS ECS, Google Cloud Run, or your own Kubernetes cluster.