SvelteKit MVP Boilerplate

A modern, full-stack SvelteKit boilerplate with Drizzle ORM, PostgreSQL, TailwindCSS, authentication and more ready to go.

Questions? Want to contribute? Need help? Found a bug?

  • Open an issue on GitHub if you found a bug
  • Submit a PR if you have a fix or a feature you want to add
  • Start a discussion for general questions or feedback
  • Ask for help in the discussions section

Tech Stack

  • ๐Ÿš€ SvelteKit 2.0+ - Latest version
  • ๐Ÿ”„ Svelte 5.0 - With runes
  • ๐ŸŽจ TailwindCSS 4.0 - Utility-first styling
  • ๐ŸŽจ Bits-UI - Headless UI components
  • ๐Ÿ—ƒ๏ธ Drizzle ORM - Type-safe database queries and Drizzle-kit for migrations
  • ๐Ÿ˜ PostgreSQL - Database
  • ๐Ÿ”’ Better-auth - Authentication system, check their docs for plugins:
    • Email/password authentication
    • Social/oauth login
    • Rate limiting
    • Handle payments andsubscriptions with Stripe or Polar
    • Organizations/teams
  • ๐Ÿ“ฆ Bun - Fast JavaScript runtime and package manager
  • ๐Ÿงฉ TypeScript - For type safety throughout the codebase
  • ๐Ÿงน Prettier - Code formatting with Tailwind plugin
  • ๐Ÿงช Vite - Build tool

Getting Started

Prerequisites

  • Bun (recommended) or Node.js 22+
  • PostgreSQL database

Installation

  1. Clone this repository

    git clone https://github.com/thomasmolorg/sveltekit-boilerplate.git
    cd sveltekit-mvp-boilerplate
    
  2. Install dependencies

    bun install
    
  3. Set up your environment variables

    cp .env.example .env
    

    Edit the .env file with your database credentials and other configuration.

  4. Run database migrations

    bun run db:migrate
    
  5. Start the development server

    bun run dev
    

Database Management

  • Generate migrations: bun run db:generate
  • Run migrations: bun run db:migrate
  • Open Drizzle Studio: bun run db:studio

Project Structure

โ”œโ”€โ”€ drizzle/             # Database migrations
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ lib/             # Shared utilities and components
โ”‚   โ”‚   โ”œโ”€โ”€ server/      # Server-only code
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ db/      # Database schema and connection
โ”‚   โ”œโ”€โ”€ routes/          # SvelteKit routes
โ”‚   โ”‚   โ”œโ”€โ”€ app/         # Protected application routes
โ”‚   โ”‚   โ””โ”€โ”€ (auth)/      # Authentication routes
โ”‚   โ”œโ”€โ”€ hooks.server.ts  # SvelteKit hooks for auth and more
โ”œโ”€โ”€ static/              # Static assets
โ”œโ”€โ”€ drizzle.config.ts    # Drizzle ORM configuration
โ””โ”€โ”€ svelte.config.js     # SvelteKit configuration

Authentication

This boilerplate includes a pre-configured authentication system using better-auth. It provides:

  • User registration and login
  • Session management
  • Protected routes

Deployment

This boilerplate can be deployed to any platform that supports SvelteKit applications:

  • Vercel
  • Netlify
  • Cloudflare Pages
  • Railway
  • Fly.io
  • Self-hosted with Node.js or Bun on e.g. AWS, Azure, etc.

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

Top categories

svelte logo

Need a Svelte website built?

Hire a professional Svelte developer today.
Loading Svelte Themes