sveltekit-convex Svelte Themes

Sveltekit Convex

Sveltekit & Convex Reusable Project Template

šŸš€ SvelteKit + Convex Starter

A modern, type-safe, full-stack starter template for building real-time web applications with incredible developer experience.

✨ Features

  • āš”ļø SvelteKit - Modern full-stack framework with SSR, routing, and API routes
  • šŸŽØ Svelte 5 - Revolutionary reactivity with runes ($state, $derived, $effect)
  • šŸ—„ļø Convex - Real-time database with automatic sync and type-safe queries
  • šŸ” Better Auth - Flexible authentication (optional, add when needed)
  • šŸ› ļø Runed - Powerful Svelte 5 utility library
  • āš ļø Neverthrow - Functional error handling with Result types
  • šŸ“¦ Bun - Fast JavaScript runtime and package manager
  • šŸ”’ End-to-end TypeScript - Full type safety from database to UI

šŸŽÆ Why This Stack?

  • Real-time by Default: Convex automatically syncs data across clients via WebSockets
  • Type-Safe Everywhere: Database schemas, API calls, and UI components are fully typed
  • Developer Experience: Minimal boilerplate, maximum productivity with Svelte 5 runes
  • Modern Patterns: Functional error handling, reactive utilities, and composable components
  • Fast: Bun for lightning-fast installs and builds

šŸš€ Quick Start

Prerequisites

Install Bun:

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

Create a New Project

# Clone this template
git clone https://github.com/yourusername/svelte-convex-starter my-app
cd my-app

# Install dependencies
bun install

# Start development server
bun run dev

Visit http://localhost:5173 to see your app! šŸŽ‰

šŸ“¦ Setup Convex (Optional)

If you want to use the real-time database:

# Install Convex
bun add convex convex-svelte

# Initialize Convex (creates convex/ directory)
bunx convex dev --once --configure=new

# Start Convex dev server (in a separate terminal)
bunx convex dev

šŸ” Setup Authentication (Optional)

If you need authentication:

# Install Better Auth
bun add better-auth

# Follow the setup guide in .cursor/rules/001_quick_reference.mdc

šŸ“ Project Structure

ā”œā”€ā”€ src/
│   ā”œā”€ā”€ routes/          # SvelteKit routes (pages & API endpoints)
│   ā”œā”€ā”€ lib/             # Shared components and utilities
│   └── app.html         # HTML template
ā”œā”€ā”€ convex/              # Convex backend (schemas, queries, mutations)
ā”œā”€ā”€ static/              # Static assets
ā”œā”€ā”€ .cursor/
│   └── rules/           # Comprehensive documentation for AI assistants
│       ā”œā”€ā”€ 001_quick_reference.mdc
│       ā”œā”€ā”€ 002_integration_example.mdc
│       └── 003_detailed_reference.mdc
└── svelte.config.js     # SvelteKit configuration

šŸ› ļø Available Commands

# Development
bun run dev              # Start dev server
bun run dev -- --open    # Start dev server and open browser

# Building
bun run build            # Build for production
bun run preview          # Preview production build

# Code Quality
bun run check            # Type-check your code
bun run format           # Format code with Prettier
bun run lint             # Lint code

# Convex (if using)
bunx convex dev          # Start Convex dev server
bunx convex deploy       # Deploy Convex to production

šŸ“š Documentation

This starter comes with comprehensive documentation optimized for AI assistants (Cursor, GitHub Copilot, etc.):

Key Concepts

Svelte 5 Runes

<script>
    // Reactive state
    let count = $state(0);

    // Computed values
    let doubled = $derived(count * 2);

    // Side effects
    $effect(() => {
        console.log('Count:', count);
    });
</script>

Convex Real-time Queries

<script>
    import { useQuery, useMutation } from 'convex-svelte';
    import { api } from '../convex/_generated/api';

    const posts = useQuery(api.posts.list, {});
    const createPost = useMutation(api.posts.create);
</script>

{#if $posts === undefined}
    <p>Loading...</p>
{:else}
    <ul>
        {#each $posts as post}
            <li>{post.title}</li>
        {/each}
    </ul>
{/if}

šŸŽ“ Learn More

🚨 Important Notes

  • Always use Bun, not npm or yarn
  • Use Svelte 5 runes ($state, $derived, $effect), not Svelte 4 syntax
  • Never share state on the server - causes data leakage between users
  • Remote functions are enabled by default in svelte.config.js

šŸ¤ Contributing

This is a personal starter template, but feel free to fork it and adapt it to your needs!

šŸ“ License

MIT


Built with ā¤ļø using SvelteKit, Convex, and Bun

Top categories

Loading Svelte Themes