Production-ready SvelteKit boilerplate with authentication, database, UI components, and advanced features. Ship modern web applications quickly and securely.
Preview Β· Documentation Β· Report Bug Β· Request Feature
- Features
- Tech Stack
- Quick Start
- Project Structure
- Documentation
- Environment Variables
- Database
- Authentication
- UI Components
- Advanced Features
- Testing
- Deployment
- Contributing
- License
- π Complete Auth System - Register, login, logout with session management
- οΏ½ OAuth Integration - Google and GitHub social login
- οΏ½οΈ PSecure Sessions** - HTTP-only cookies with secure flags
- π Password Hashing - Argon2 algorithm for maximum security
- πͺ Protected Routes - Automatic redirect for unauthenticated users
- οΏ½ Email rVerification - Verify user emails with tokens
- οΏ½ Passwlord Reset - Secure password recovery flow
- ποΈ PostgreSQL - Robust relational database
- π Drizzle ORM - Type-safe SQL query builder
- π Migrations - Version-controlled database schema
- π³ Docker Setup - One-command local database
- π¨ Tailwind CSS 4 - Utility-first CSS framework
- πΈ DaisyUI - Beautiful component library (32+ themes)
- π Theme Selector - Full theme support with persistence
- οΏ½ Responsive - Mobile-first design
- π§© Layout Components - Sidebar, Topbar, Centered, Split layouts
- π Form Components - Input, Select, Checkbox, Radio, Textarea, DatePicker, FileInput
- π Internationalization (i18n) - Multi-language support (EN, ID)
- π§ Email Service - Resend integration with HTML templates
- π File Storage - Local, S3, and Cloudflare R2 support
- π‘ Real-time SSE - Server-Sent Events for notifications
- π Analytics - Plausible, Umami, Google Analytics support
- π Structured Logging - JSON logging with Sentry integration
- π API Documentation - Interactive API docs page
- π οΈ CLI Generator - Generate components, routes, and APIs
- π TypeScript - Full type safety
- β‘ Vite - Lightning-fast HMR
- π§ͺ Testing - Unit, property-based, and E2E tests (476+ tests)
- π¦ Pre-built Components - 16+ UI components ready to use
| Category | Technology |
|---|---|
| Framework | SvelteKit 2 with Svelte 5 |
| Language | TypeScript 5 |
| Styling | Tailwind CSS 4 + DaisyUI 5 |
| Database | PostgreSQL 16 |
| ORM | Drizzle ORM |
| Authentication | Lucia Auth 3 |
| Resend | |
| Storage | Local / AWS S3 / Cloudflare R2 |
| Testing | Vitest + Playwright + fast-check |
| Container | Docker |
- Node.js 18+
- Docker (for PostgreSQL)
- Git
# Clone the repository
git clone https://github.com/nirvagold/svelteship.git
cd svelteship
# Install dependencies
npm install
# Copy environment variables
cp .env.example .env
# Start PostgreSQL with Docker
docker-compose up -d
# Run database migrations
npm run db:migrate
# Start development server
npm run devOpen http://localhost:5173 in your browser.
svelteship/
βββ src/
β βββ lib/
β β βββ components/
β β β βββ ui/ # UI primitives (Button, Modal, Toast, etc.)
β β β βββ forms/ # Form components (Input, Select, etc.)
β β β βββ layouts/ # Layout components (Sidebar, Topbar, etc.)
β β βββ hooks/ # Svelte hooks (useDebounce, useForm, useSSE, etc.)
β β βββ utils/ # Shared utilities (date, currency, etc.)
β β βββ i18n/ # Internationalization (locales, translations)
β β βββ analytics/ # Analytics integration
β β βββ server/ # Server-only code
β β βββ db/ # Database client & schema
β β βββ email/ # Email service & templates
β β βββ storage/ # File storage (local, S3, R2)
β β βββ oauth/ # OAuth providers (Google, GitHub)
β β βββ logger.ts # Structured logging
β β βββ sse.ts # Server-Sent Events
β β βββ auth.ts # Lucia configuration
β βββ routes/
β β βββ (auth)/ # Auth pages (login, register, logout, oauth)
β β βββ (app)/ # Protected pages (dashboard, profile, settings)
β β βββ api/ # API endpoints
β β β βββ docs/ # Interactive API documentation
β β β βββ notifications/# SSE notification stream
β β βββ docs/ # Component documentation
β β βββ +page.svelte # Landing page
β βββ examples/ # Optional features (copy if needed)
β β βββ notifications/ # Notification system
β β βββ onboarding/ # Onboarding wizard
β β βββ admin/ # Admin dashboard
β β βββ sessions/ # Session management
β β βββ security/ # Password change, 2FA
β βββ hooks.server.ts # Session validation middleware
βββ scripts/
β βββ generate.ts # CLI generator for components/routes/APIs
βββ drizzle/ # Database migrations
βββ e2e/ # Playwright E2E tests
βββ static/ # Static assets
βββ docker-compose.yml # PostgreSQL container
| Command | Description |
|---|---|
npm run dev |
Start development server |
npm run build |
Build for production |
npm run preview |
Preview production build |
npm run check |
Run svelte-check |
npm run test |
Run unit tests |
npm run test:e2e |
Run E2E tests |
npm run lint |
Run ESLint |
npm run db:generate |
Generate migrations |
npm run db:migrate |
Run migrations |
npm run db:studio |
Open Drizzle Studio |
npm run generate |
CLI generator for components/routes/APIs |
Create a .env file in the root directory. See .env.example for all available options:
# Database
DATABASE_URL=postgres://svelteship:svelteship@localhost:5432/svelteship
# OAuth (optional)
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
# Email (optional)
EMAIL_PROVIDER=console # or "resend"
RESEND_API_KEY=
# Storage (optional)
STORAGE_PROVIDER=local # or "s3", "r2"
# Analytics (optional)
ANALYTICS_PROVIDER= # "plausible", "umami", "google", "custom"The database includes these main tables:
| Table | Description |
|---|---|
users |
User accounts with email, password, preferences |
sessions |
Active user sessions |
oauth_accounts |
Linked OAuth providers (Google, GitHub) |
email_verification_tokens |
Email verification tokens |
password_reset_tokens |
Password reset tokens |
# Start PostgreSQL
docker-compose up -d
# Stop PostgreSQL
docker-compose down
# Generate new migration
npm run db:generate
# Apply migrations
npm run db:migrate
# Open database GUI
npm run db:studioSvelteship uses Lucia Auth for authentication.
- Registration - Email/password with validation
- Login - Secure session creation
- Logout - Session invalidation
- OAuth - Google and GitHub social login
- Email Verification - Verify user emails
- Password Reset - Secure recovery flow
- Protected Routes - Automatic auth guards
- Session Refresh - Automatic token renewal
- Create OAuth app on Google Cloud Console or GitHub Developer Settings
- Add credentials to
.env:GOOGLE_CLIENT_ID=your-client-id GOOGLE_CLIENT_SECRET=your-client-secret GITHUB_CLIENT_ID=your-client-id GITHUB_CLIENT_SECRET=your-client-secret
- OAuth buttons will appear on login page automatically
| Component | Description |
|---|---|
| Button | Buttons with variants, sizes, loading state |
| Modal | Dialog with backdrop, sizes, close button |
| Toast | Notification toasts with auto-dismiss |
| ConfirmDialog | Confirmation dialogs with callbacks |
| Dropdown | Dropdown menus with keyboard navigation |
| Tabs | Tab navigation with panels |
| Accordion | Collapsible content sections |
| Table | Data tables with sorting |
| Pagination | Page navigation with ellipsis |
| Tooltip | Hover tooltips with positions |
| Badge | Status badges with variants |
| Avatar | User avatars with fallback |
| Progress | Progress bars with animation |
| Spinner | Loading spinners |
| Skeleton | Loading placeholders |
| Breadcrumb | Navigation breadcrumbs |
| Component | Description |
|---|---|
| Input | Text input with label, error, helper text |
| Select | Dropdown select with options |
| Checkbox | Checkbox with label |
| Radio | Radio group with options |
| Textarea | Multi-line input with character count |
| DatePicker | Date selection with min/max |
| FileInput | File upload with drag-drop and preview |
<script>
import { SidebarLayout, TopbarLayout, CenteredLayout, SplitLayout } from '$lib/components/layouts';
</script>
<!-- Sidebar navigation -->
<SidebarLayout navItems={items} collapsible>
<main>Content</main>
</SidebarLayout>
<!-- Top navigation bar -->
<TopbarLayout navItems={items} sticky>
<main>Content</main>
</TopbarLayout>
<!-- Centered content (auth pages) -->
<CenteredLayout size="md" background="gradient">
<div class="card">Login form</div>
</CenteredLayout>
<!-- Two-column layout -->
<SplitLayout ratio="1/2">
{#snippet left()}<aside>Sidebar</aside>{/snippet}
{#snippet right()}<main>Content</main>{/snippet}
</SplitLayout>import { t, locale, setLocale } from '$lib/i18n';
// Get translation
const greeting = t('common.welcome'); // "Welcome" or "Selamat Datang"
// Change language
setLocale('id'); // Switch to Indonesian
// Format date/number by locale
import { formatDate, formatNumber } from '$lib/i18n';
formatDate(new Date()); // "December 30, 2024" or "30 Desember 2024"
formatNumber(1234.56); // "1,234.56" or "1.234,56"import { sendEmail } from '$lib/server/email';
// Send verification email
await sendEmail({
to: 'user@example.com',
subject: 'Verify your email',
template: 'verification',
variables: { name: 'John', link: 'https://...' }
});import { storage } from '$lib/server/storage';
// Upload file
const url = await storage.upload(file, 'uploads/avatar.png');
// Delete file
await storage.delete('uploads/avatar.png');
// List files
const files = await storage.list('uploads/');// Client-side
import { useSSE } from '$lib/hooks/useSSE';
const { data, error, connected } = useSSE('/api/notifications/stream');
$effect(() => {
if (data) {
console.log('New notification:', data);
}
});# Generate a new component
npm run generate
# Select: component
# Name: MyComponent
# Creates: src/lib/components/ui/MyComponent.svelte
# Generate a new route
npm run generate
# Select: route
# Path: /dashboard/analytics
# Creates: src/routes/dashboard/analytics/+page.svelte
# Generate a new API endpoint
npm run generate
# Select: api
# Path: /api/users
# Creates: src/routes/api/users/+server.tsOptional features in src/examples/ that you can copy into your project:
| Example | Description |
|---|---|
notifications/ |
Full notification system with database |
onboarding/ |
Multi-step onboarding wizard |
admin/ |
Admin dashboard with role-based access |
sessions/ |
Session management UI |
security/ |
Password change, 2FA settings |
# Example: Add notifications
cp -r src/examples/notifications src/routes/(app)/notificationsEach example includes README with setup instructions.
Svelteship includes comprehensive testing with 476+ tests:
# Run unit tests
npm run test
# Run with coverage
npm run test -- --coverage# Run E2E tests
npm run test:e2e
# Run with UI
npm run test:e2e:ui- β Input validation (email, password)
- β Authentication flows (register, login, logout, OAuth)
- β Protected route guards
- β Profile management
- β Theme persistence
- β Form components
- β i18n translations
- β Email service
- β File storage
- β SSE hooks
- β Analytics
npm install -g vercel
vercelFROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
EXPOSE 3000
CMD ["node", "build"]Set these environment variables in your deployment platform:
DATABASE_URL- PostgreSQL connection stringNODE_ENV- Set toproduction- OAuth, Email, Storage credentials as needed
Contributions are welcome! Please read our Contributing Guide first.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- SvelteKit - The web framework
- Lucia Auth - Authentication library
- Drizzle ORM - Database toolkit
- DaisyUI - Component library
- Tailwind CSS - CSS framework
- Resend - Email service
Made with β€οΈ by the Svelteship Team