SvelteKit template with authentication, database, UI components, and PWA support.
- SvelteKit - Full-stack web framework with Svelte 5 runes
- Tailwind CSS 4 - Utility-first CSS framework
- shadcn-svelte - UI component library
- Better Auth - Authentication with GitHub OAuth
- Drizzle ORM - Type-safe database queries
- Turso - SQLite edge database
- TypeScript - Type safety throughout
- PWA - Progressive web app with offline support
| Technology | Purpose | Version |
|---|---|---|
| SvelteKit | Full-stack framework | ^2.22.0 |
| Svelte | Frontend framework | ^5.0.0 |
| Tailwind CSS | CSS framework | ^4.0.0 |
| shadcn-svelte | UI components | bits-ui |
| Better Auth | Authentication | ^1.3.9 |
| Drizzle ORM | Database ORM | ^0.40.0 |
| Turso | SQLite database | libSQL |
| TypeScript | Type safety | ^5.0.0 |
| Workbox | PWA service worker | ^7.0.0 |
src/
├── lib/
│ ├── components/
│ │ └── ui/ # shadcn-svelte components
│ ├── server/
│ │ ├── auth.ts # Better Auth configuration
│ │ └── db/ # Database setup and schema
│ ├── auth-client.ts # Client-side auth helpers
│ ├── utils.ts # Utility functions
│ └── pwa.ts # PWA initialization
├── routes/
│ ├── api/
│ │ └── auth/ # Auth API endpoints
│ ├── auth/ # Authentication pages
│ ├── dashboard/ # Protected dashboard
│ └── +layout.svelte # Root layout
└── app.css # Global styles with Tailwind
- Node.js 18+ or Bun
- A GitHub OAuth app
- A Turso database
git clone <repository-url>
cd aMaDrOfSvelte
bun install # or npm installCopy the example environment file:
cp .env.example .envConfigure your environment variables:
# Database (Turso)
DATABASE_URL="libsql://your-database-name.turso.io"
DATABASE_AUTH_TOKEN="your-turso-auth-token"
# Authentication
BETTER_AUTH_SECRET="your-super-secret-key-min-32-chars"
BETTER_AUTH_URL="http://localhost:5173"
# GitHub OAuth
GITHUB_CLIENT_ID="your-github-client-id"
GITHUB_CLIENT_SECRET="your-github-client-secret"
# Environment
NODE_ENV="development"Create and push your database schema:
bun run db:generate # Generate migrations
bun run db:push # Apply to databaseOptional: Open Drizzle Studio to view your database:
bun run db:studio- Go to GitHub Developer Settings
- Create a new OAuth App with:
- Application name: Your app name
- Homepage URL:
http://localhost:5173 - Authorization callback URL:
http://localhost:5173/api/auth/callback/github
- Copy the Client ID and Client Secret to your
.envfile
bun run dev # or npm run devVisit http://localhost:5173 to see your app!
- Install Turso CLI:
curl -sSfL https://get.tur.so/install.sh | bash- Create a database:
turso db create amadrofsvelte- Get your database URL and create a token:
turso db show amadrofsvelte # Get the URL
turso db tokens create amadrofsvelte # Create auth token- Add the URL and token to your
.envfile
For local development, you can use a local SQLite file:
DATABASE_URL="file:./local.db"
# Remove or leave empty: DATABASE_AUTH_TOKEN=""Authentication flow:
- Public Pages - Home page accessible to everyone
- Protected Routes - Dashboard requires authentication
- Auth Redirect - Unauthenticated users redirected to sign-in
- Session Management - Persistent sessions with Better Auth
- Sign Out - Clean session termination
Better Auth supports many providers. To add more:
- Update
src/lib/server/auth.ts:
socialProviders: {
github: { /* existing config */ },
google: {
clientId: env.GOOGLE_CLIENT_ID || '',
clientSecret: env.GOOGLE_CLIENT_SECRET || ''
}
}- Add environment variables to
.env - Update the sign-in UI in
/authpage
The template includes PWA functionality with:
- Service Worker - Workbox for caching and offline support
- Web Manifest - App metadata and icon configuration
- Install Prompt - Native install prompts for supported browsers
- Offline Support - Basic caching for static assets
The PWA is configured through:
static/manifest.json- App manifest with icons and metadatasrc/pwa.ts- Service worker registration and managementsrc/lib/components/PWAInstallPrompt.svelte- Install prompt component
Update static/manifest.json for app metadata:
{
"name": "Your App Name",
"short_name": "AppName",
"description": "App description",
"theme_color": "#your-color",
"background_color": "#your-bg-color"
}Included components:
- Button - Multiple variants and sizes
- Card - Content containers
- Input - Form inputs
- Label - Form labels
- Alert - Status messages
- Badge - Status indicators
- Tabs - Tabbed interfaces
- Select - Dropdown selections
- Switch - Toggle controls
- Textarea - Multi-line inputs
- Separator - Visual dividers
- PWA Install Prompt - Native app installation
Use the shadcn-svelte CLI or copy components manually:
npx shadcn-svelte add dialog
npx shadcn-svelte add toastFeatures:
- Vite Plugin: No PostCSS configuration needed
- OKLCH Colors: Modern color space support
- Custom Properties: CSS custom properties for theming
- Dark Mode: Built-in dark mode support
- Modern Features:
@themedirective and more
Color system:
:root {
--color-background: oklch(1 0 0);
--color-foreground: oklch(0.129 0.042 264.695);
--color-primary: oklch(0.208 0.042 265.755);
/* ... more colors */
}| Command | Description |
|---|---|
bun run dev |
Start development server |
bun run build |
Build for production |
bun run preview |
Preview production build |
bun run check |
Run type checking |
bun run check:watch |
Type checking in watch mode |
bun run format |
Format code with Prettier |
bun run lint |
Check code formatting |
bun run db:generate |
Generate database migrations |
bun run db:push |
Push schema to database |
bun run db:migrate |
Run database migrations |
bun run db:studio |
Open Drizzle Studio |
- Push your code to GitHub
- Connect your repository to Vercel
- Add environment variables in Vercel dashboard
- Update
BETTER_AUTH_URLto your production domain - Update GitHub OAuth callback URL
Works on any Node.js platform. Update the adapter in svelte.config.js:
import adapter from '@sveltejs/adapter-node'; // or adapter-vercel, etc.Modify colors in src/app.css:
:root {
--color-primary: oklch(0.5 0.2 250); /* Custom blue */
/* Update other colors as needed */
}- Add tables to
src/lib/server/db/schema.ts - Generate migrations:
bun run db:generate - Apply changes:
bun run db:push
Create new components in src/lib/components/:
<!-- src/lib/components/CustomButton.svelte -->
<script lang="ts">
import { Button } from './ui/button';
let { children, ...props } = $props();
</script>
<Button {...props}>
{@render children?.()}
</Button>- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes
- Run tests:
bun run check - Commit:
git commit -m 'Add feature' - Push:
git push origin feature-name - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE.md file for details.
- SvelteKit for the amazing framework
- shadcn/ui for component design inspiration
- Better Auth for secure authentication
- Drizzle for type-safe database queries
- Turso for edge database hosting
Built for developers who want to ship fast.