svelte Svelte Themes

Svelte

A modern cookiecutter template for Svelte5 projects that use bun for dependency management

Svelte 5 Cookiecutter Template

A modern cookiecutter template for Svelte 5 projects with TypeScript, Tailwind CSS, and Bun.

Features

  • ๐Ÿš€ Svelte 5 with SvelteKit
  • ๐Ÿ“˜ TypeScript support
  • ๐ŸŽจ Tailwind CSS for styling
  • โšก Bun for fast package management and runtime
  • ๐Ÿงช Vitest for testing (optional)
  • ๐Ÿณ Docker support (optional)
  • ๐Ÿ”ง ESLint and Prettier for code quality
  • ๐Ÿ“ Well-organized project structure with useful path aliases
  • ๐ŸŽฏ Modern tooling with optimized configurations

Project Structure

The generated project includes:

your-project/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ lib/
โ”‚   โ”‚   โ”œโ”€โ”€ components/          # Reusable UI components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ui/             # Basic UI elements
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ features/       # Feature-specific components
โ”‚   โ”‚   โ”œโ”€โ”€ utils/              # Utility functions
โ”‚   โ”‚   โ”œโ”€โ”€ hooks/              # Custom Svelte 5 runes/hooks
โ”‚   โ”‚   โ”œโ”€โ”€ stores/             # Svelte stores
โ”‚   โ”‚   โ”œโ”€โ”€ api/                # API functions
โ”‚   โ”‚   โ”œโ”€โ”€ config/             # Application configuration
โ”‚   โ”‚   โ”œโ”€โ”€ assets/             # Static assets
โ”‚   โ”‚   โ””โ”€โ”€ vendor/             # Third-party components
โ”‚   โ”œโ”€โ”€ routes/                 # SvelteKit routes
โ”‚   โ”œโ”€โ”€ styles/                 # Global styles
โ”‚   โ”œโ”€โ”€ app.html               # HTML template
โ”‚   โ”œโ”€โ”€ app.css               # Main CSS entry point
โ”‚   โ””โ”€โ”€ app.d.ts              # TypeScript declarations
โ”œโ”€โ”€ static/                     # Static files
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ svelte.config.js
โ”œโ”€โ”€ vite.config.ts
โ”œโ”€โ”€ tailwind.config.js
โ””โ”€โ”€ tsconfig.json

Quick Start

Prerequisites

Generate a New Project

uvx cookiecutter https://github.com/mort-sh/svelte.git

Using cookiecutter

pip install cookiecutter
cookiecutter https://github.com/mort-sh/svelte.git

Using cookiecutter directly from GitHub

cookiecutter gh:mort-sh/svelte

Project Setup

After generating your project:

  1. Navigate to your project directory:

    cd your-project-name
    
  2. Install Bun if you haven't already:

    curl -fsSL https://bun.sh/install | bash
    
  3. Install dependencies:

    bun install
    
  4. Start the development server:

    bun dev
    
  5. Open your browser and visit http://localhost:5173 (or the port you configured)

Template Configuration

When you run the cookiecutter command, you'll be prompted to configure:

  • project_name: The display name of your project
  • project_slug: The directory/package name (auto-generated from project_name)
  • project_description: A brief description of your project
  • author_name: Your name
  • author_email: Your email address
  • author_github_handle: Your GitHub username
  • dev_port: Development server port (default: 5173)
  • preview_port: Preview server port (default: 3000)
  • include_docker: Include Docker configuration (y/n)
  • include_testing: Include Vitest testing setup (y/n)
  • open_source_license: Choose your license type

Available Scripts

The generated project includes these scripts:

  • bun dev - Start development server
  • bun run build - Build for production
  • bun run preview - Preview production build
  • bun run check - Run TypeScript and Svelte checks
  • bun run format - Format code with Prettier
  • bun run lint - Lint code with ESLint
  • bun run test - Run tests (if testing is enabled)

Docker Support

If you enabled Docker support, you can:

# Build the image
docker build -t your-app .

# Run the container  
docker run -p 3000:3000 your-app

Path Aliases

The template sets up convenient path aliases:

  • $lib โ†’ src/lib
  • $components โ†’ src/lib/components
  • $ui โ†’ src/lib/components/ui
  • $features โ†’ src/lib/components/features
  • $utils โ†’ src/lib/utils
  • $assets โ†’ src/lib/assets
  • $hooks โ†’ src/lib/hooks
  • $stores โ†’ src/lib/stores
  • $api โ†’ src/lib/api
  • $config โ†’ src/lib/config
  • $vendor โ†’ src/lib/vendor

Use them in your imports:

import Button from '$ui/Button.svelte';
import { formatDate } from '$utils/date.js';

Learn More

Contributing

Issues and pull requests are welcome! Please feel free to contribute to make this template even better.

License

This template is released under the MIT License.

Top categories

svelte logo

Need a Svelte website built?

Hire a professional Svelte developer today.
Loading Svelte Themes