A comprehensive, production-ready SaaS starter kit built with SvelteKit 5, featuring complete authentication, AI integration, file uploads, and modern UI components. Launch your SaaS product quickly with all essential features pre-configured.
saas-starter-kit/
āāā src/
ā āāā routes/ # SvelteKit routes
ā ā āāā (legal)/ # Legal pages (route group)
ā ā ā āāā privacy-policy/ # Privacy policy
ā ā ā āāā terms-of-service/ # Terms of service
ā ā āāā dashboard/ # Protected dashboard (requires auth)
ā ā ā āāā +page.svelte # Dashboard overview with stats
ā ā ā āāā chat/ # AI chat interface
ā ā ā āāā upload/ # File upload with R2
ā ā ā āāā settings/ # User settings
ā ā āāā pricing/ # Public pricing page
ā ā āāā sign-in/ # Email/password + Google OAuth login
ā ā āāā sign-up/ # Registration with validation
ā ā āāā forgot-password/ # Password reset request
ā ā āāā reset-password/ # Password reset with token
ā ā āāā verify-email/ # Email verification
ā ā āāā api/ # API endpoints
ā ā āāā auth/ # Better Auth API routes
ā ā āāā chat/ # AI chat streaming API
ā ā āāā upload-image/ # R2 upload API
ā āāā lib/
ā ā āāā components/ # 116 Svelte components
ā ā ā āāā ui/ # shadcn-svelte (27 component groups)
ā ā ā āāā homepage/ # HeroSection, Integrations, Footer
ā ā ā āāā dashboard/ # Sidebar, Navbar, Charts, Stats
ā ā ā āāā common/ # GetStartedButton, UserProfile
ā ā ā āāā logos/ # Brand logos
ā ā āāā server/ # Server-side modules
ā ā ā āāā auth.ts # Better Auth config (16,739 lines)
ā ā ā āāā upload-image.ts # R2 file upload logic
ā ā ā āāā db/ # Database schema & connection
ā ā ā āāā index.ts # Neon connection
ā ā ā āāā schema.ts # Drizzle schema (7 tables)
ā ā āāā stores/ # Svelte stores
ā ā ā āāā auth.ts # Auth state management
ā ā āāā types/ # TypeScript type definitions
ā ā āāā utils/ # Helper functions
ā āāā hooks.server.ts # Session management & route protection
ā āāā app.css # Global Tailwind styles
āāā drizzle/ # Database migrations
ā āāā migrations/ # SQL migration files
āāā static/ # Static assets
āāā components.json # shadcn-svelte config
āāā svelte.config.js # SvelteKit config (path aliases)
āāā tailwind.config.ts # Tailwind CSS v4 config
āāā drizzle.config.ts # Drizzle Kit config
āāā .env # Environment variables
Clone the repository
git clone <repository-url>
cd svelte-starter-kit
Install dependencies
npm install
Environment Setup
Create a .env file based on .env.example:
```env
PUBLIC_APP_URL=http://localhost:3000
DATABASE_URL=postgresql://username:password@host.neon.tech/database?sslmode=require
BETTER_AUTH_SECRET=your-secret-key-here
GOOGLE_CLIENT_ID=your-google-client-id.apps.googleusercontent.com GOOGLE_CLIENT_SECRET=your-google-client-secret
OPENAI_API_KEY=your-openai-api-key
RESEND_API_KEY=re_123456789 RESEND_FROM_EMAIL=noreply@example.com
CLOUDFLARE_ACCOUNT_ID=your-cloudflare-account-id R2_UPLOAD_IMAGE_ACCESS_KEY_ID=your-r2-access-key-id R2_UPLOAD_IMAGE_SECRET_ACCESS_KEY=your-r2-secret-access-key R2_UPLOAD_IMAGE_BUCKET_NAME=your-r2-bucket-name
4. **Database Setup**
```bash
# Generate and run migrations
npx drizzle-kit generate
npx drizzle-kit push
# Optional: Open Drizzle Studio to view your database
npx drizzle-kit studio
src/lib/server/upload-image.ts:25http://localhost:3000 (and your production URL)http://localhost:3000/api/auth/callback/google (and your production URL).env fileRESEND_API_KEY in your .envRESEND_FROM_EMAIL to your verified sender emailnpm run dev
Open http://localhost:3000 to see your application.
Powered by Better Auth with comprehensive security
Multiple Auth Methods:
Email Verification:
Password Management:
Session Management:
Security Features:
Flow: hooks.server.ts ā event.locals.session ā Protected routes check auth ā Redirect if needed
Powered by Vercel AI SDK + OpenAI
Features:
nvidia/kimi-k2-thinking)Implementation:
src/routes/api/chat/+server.tsstreamText() for streaming responsesUI Features:
Flow: User types ā POST /api/chat ā OpenAI processes ā Stream response ā Display in real-time
Powered by Cloudflare R2 (S3-compatible)
Storage Features:
Upload Features:
Image Gallery:
API Endpoint (src/routes/api/upload-image/+server.ts):
Flow: Drag/drop file ā Validate ā Upload to R2 ā Return URL ā Display in gallery
Interactive dashboard with real-time data
Overview Page:
Navigation:
Protected Features:
27 component groups with 116 Svelte components
Form Components: Input, Label, Button, Checkbox, Select, Textarea, Toggle, Slider Layout Components: Card, Separator, Tabs, Sheet (mobile drawer) Feedback Components: Badge, Progress, Skeleton, Sonner (toast notifications) Overlay Components: Dialog, Dropdown Menu, Tooltip Data Display: Table, Avatar Advanced: Resizable panes, Toggle groups
Design System:
# Start development server (runs on http://0.0.0.0:3000)
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview
# Type checking
npm run check
# Type checking in watch mode
npm run check:watch
# Database migrations (Drizzle)
npx drizzle-kit generate # Generate migrations from schema
npx drizzle-kit migrate # Run migrations
npx drizzle-kit push # Push schema changes directly (dev only)
npx drizzle-kit studio # Open Drizzle Studio GUI
src/lib/components/src/routes/api/npx @better-auth/cli generate to explore available Better Auth schemas that you might needsrc/lib/server/db/schema.tsdrizzleAdapter configuration in src/lib/server/auth.tsnpx drizzle-kit generate to create SQL migration filesnpx drizzle-kit push to apply changes to your Neon databasenpx drizzle-kit studio to inspect your database schemasrc/app.css for global stylescomponents.jsonsrc/lib/server/auth.tsConfigured in svelte.config.js:
$components ā src/lib/components$server ā src/lib/server$lib ā src/lib (SvelteKit default)event.locals.session/sign-in/api/upload-image/api/chat endpointnpm run build
npm run preview
Note: You may need to install a specific adapter for your target environment.
.env.examplesrc/lib/server/upload-image.ts:25 with your actual domain.env file to version control5 tables with migrations:
user - User accountssession - Session managementaccount - OAuth provider accountsverification - Email verification tokensrate_limit - Rate limiting storageAfter schema changes:
npx drizzle-kit generate to create migrationsdrizzle/migrations/npx drizzle-kit push to apply changes.env fileCurrent Language: Chinese (Simplified)
To change language, update text in:
src/routes/sign-in/+page.sveltesrc/routes/sign-up/+page.sveltesrc/lib/server/auth.ts (email templates)This starter kit is perfect for building:
Potential future enhancements:
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
Built with these amazing technologies:
Built with ā¤ļø using SvelteKit and modern web technologies.
Ready to launch your SaaS? Star this repo and get started! ā