SvelteKit template with authentication, database, UI components, and PWA 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
git clone <repository-url>
cd aMaDrOfSvelte
bun install # or npm install
Copy the example environment file:
cp .env.example .env
Configure 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 database
Optional: Open Drizzle Studio to view your database:
bun run db:studio
http://localhost:5173
http://localhost:5173/api/auth/callback/github
.env
filebun run dev # or npm run dev
Visit http://localhost:5173 to see your app!
curl -sSfL https://get.tur.so/install.sh | bash
turso db create amadrofsvelte
turso db show amadrofsvelte # Get the URL
turso db tokens create amadrofsvelte # Create auth token
.env
fileFor local development, you can use a local SQLite file:
DATABASE_URL="file:./local.db"
# Remove or leave empty: DATABASE_AUTH_TOKEN=""
Authentication flow:
Better Auth supports many providers. To add more:
src/lib/server/auth.ts
:socialProviders: {
github: { /* existing config */ },
google: {
clientId: env.GOOGLE_CLIENT_ID || '',
clientSecret: env.GOOGLE_CLIENT_SECRET || ''
}
}
.env
/auth
pageThe template includes PWA functionality with:
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 componentUpdate 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:
Use the shadcn-svelte CLI or copy components manually:
npx shadcn-svelte add dialog
npx shadcn-svelte add toast
Features:
@theme
directive and moreColor 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 |
BETTER_AUTH_URL
to your production domainWorks 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 */
}
src/lib/server/db/schema.ts
bun run db:generate
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>
git checkout -b feature-name
bun run check
git commit -m 'Add feature'
git push origin feature-name
This project is licensed under the MIT License - see the LICENSE.md file for details.
Built for developers who want to ship fast.