convex-sveltekit-boilerplate Svelte Themes

Convex Sveltekit Boilerplate

Modern SaaS boilerplate with SvelteKit 5, Convex, Better Auth, Stripe billing, and more

๐Ÿš€ Convex SvelteKit Boilerplate

A production-ready, modern SaaS boilerplate built with the latest web technologies. This template provides everything you need to launch your next project quickly and efficiently.

โœจ Features

Core Technologies

  • ๐ŸŽจ SvelteKit with Svelte 5 - Modern, reactive frontend framework with the latest Runes API
  • ๐Ÿ”ฅ Convex - Real-time backend database with serverless functions
  • ๐Ÿ” Better Auth - Comprehensive authentication solution with email/password and OAuth
  • ๐Ÿ’ณ Autumn - Stripe billing wrapper for seamless payment integration
  • ๐Ÿ“ง Resend - Transactional email service for password resets and email verification
  • ๐ŸŽญ shadcn-svelte - Beautiful, accessible UI components
  • ๐Ÿ’จ Tailwind CSS v4 - Utility-first CSS framework (latest version)
  • ๐ŸŽฏ Lucide - Beautiful icon library
  • ๐Ÿ“Š PostHog - Product analytics and feature flags
  • ๐Ÿช„ Runed - Powerful utilities for Svelte 5
  • โœ… Neverthrow - Type-safe error handling with Result types
  • ๐Ÿค– Vercel AI SDK - AI-powered features with Anthropic integration

Built-in Features

โœ… Authentication System

  • Email/password authentication
  • Google OAuth support (configurable)
  • Password reset flow
  • Email verification
  • Session management

โœ… User Management

  • User profile settings
  • Avatar upload with Convex storage
  • Account information management

โœ… Subscription & Billing

  • Stripe integration via Autumn
  • Subscription management
  • Payment processing
  • Billing history

โœ… UI Components

  • Dashboard with sidebar-07 layout from shadcn-svelte
  • Responsive design
  • Dark/light mode support
  • Accessible components

โœ… Developer Experience

  • TypeScript throughout
  • Type-safe database queries
  • Hot module replacement
  • ESLint & Prettier configured
  • Result-based error handling with neverthrow

๐Ÿ“‹ Prerequisites

๐Ÿš€ Quick Start

1. Clone the repository

git clone https://github.com/yourusername/convex-sveltekit-boilerplate.git
cd convex-sveltekit-boilerplate

2. Install dependencies

pnpm install
# or
npm install

3. Set up environment variables

Copy .env.example to .env.local:

cp .env.example .env.local

Fill in your environment variables:

# Convex
PUBLIC_CONVEX_URL=your_convex_url
PUBLIC_CONVEX_SITE_URL=your_convex_site_url

# Site
SITE_URL=http://localhost:5173

# Better Auth
BETTER_AUTH_SECRET=your_auth_secret # Generate with: openssl rand -base64 32
BETTER_AUTH_URL=http://localhost:5173

# OAuth (Optional)
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret

# Resend
RESEND_API_KEY=your_resend_api_key
RESET_EMAIL_FROM="Your App <[email protected]>"
[email protected]

# Autumn (Stripe)
AUTUMN_API_KEY=your_autumn_api_key
PUBLIC_AUTUMN_PUBLISHABLE_KEY=your_autumn_publishable_key

# PostHog
PUBLIC_POSTHOG_API_KEY=your_posthog_api_key
PUBLIC_POSTHOG_HOST=https://app.posthog.com

# Anthropic (for AI SDK)
ANTHROPIC_API_KEY=your_anthropic_api_key

4. Initialize Convex

pnpm convex dev

This will:

  • Create a new Convex project (or link to existing)
  • Set up your database schema
  • Start the Convex dev server

5. Start the development server

In a new terminal:

pnpm dev

The app will be running at http://localhost:5173

๐Ÿ“ Project Structure

convex-sveltekit-boilerplate/
โ”œโ”€โ”€ convex/                      # Convex backend
โ”‚   โ”œโ”€โ”€ schema.ts               # Database schema
โ”‚   โ”œโ”€โ”€ auth.ts                 # Authentication config
โ”‚   โ”œโ”€โ”€ users.ts                # User queries/mutations
โ”‚   โ””โ”€โ”€ subscriptions.ts        # Subscription queries/mutations
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ lib/
โ”‚   โ”‚   โ”œโ”€โ”€ components/         # Reusable components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ui/            # shadcn-svelte components
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ app-sidebar.svelte
โ”‚   โ”‚   โ”œโ”€โ”€ server/            # Server-only code
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ auth.ts        # Better Auth server config
โ”‚   โ”‚   โ”œโ”€โ”€ utils/             # Utility functions
โ”‚   โ”‚   โ”œโ”€โ”€ auth-client.ts     # Auth client
โ”‚   โ”‚   โ”œโ”€โ”€ convex-client.ts   # Convex client
โ”‚   โ”‚   โ””โ”€โ”€ analytics.ts       # PostHog config
โ”‚   โ””โ”€โ”€ routes/
โ”‚       โ”œโ”€โ”€ (app)/             # Protected routes
โ”‚       โ”‚   โ”œโ”€โ”€ dashboard/     # Dashboard pages
โ”‚       โ”‚   โ””โ”€โ”€ +layout.svelte # App layout with sidebar
โ”‚       โ”œโ”€โ”€ (auth)/            # Auth routes
โ”‚       โ”‚   โ””โ”€โ”€ auth/
โ”‚       โ”‚       โ”œโ”€โ”€ signin/
โ”‚       โ”‚       โ””โ”€โ”€ signup/
โ”‚       โ””โ”€โ”€ +page.svelte       # Landing page
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ svelte.config.js
โ”œโ”€โ”€ vite.config.ts
โ””โ”€โ”€ tailwind.config.js

๐Ÿ”ง Development

Running both servers

For the best development experience, run both servers in parallel:

# Terminal 1 - Convex backend
pnpm convex dev

# Terminal 2 - SvelteKit frontend
pnpm dev

Available Scripts

  • pnpm dev - Start development server
  • pnpm build - Build for production
  • pnpm preview - Preview production build
  • pnpm lint - Lint code
  • pnpm format - Format code with Prettier
  • pnpm check - Type-check with svelte-check
  • pnpm convex:dev - Start Convex dev server
  • pnpm convex:deploy - Deploy Convex backend

๐Ÿšข Deployment

Deploy to Vercel

  1. Deploy your Convex backend:
pnpm convex deploy
  1. Deploy your frontend to Vercel:

  1. Set environment variables in Vercel:

Go to your Vercel project settings and add all the environment variables from .env.example.

Make sure to update:

  • SITE_URL to your production domain
  • BETTER_AUTH_URL to your production domain
  • PUBLIC_CONVEX_URL to your production Convex URL

๐ŸŽจ Customization

Adding shadcn-svelte Components

This template uses shadcn-svelte for UI components. To add more components:

npx shadcn-svelte@latest add [component-name]

Configuring Better Auth

Edit src/lib/server/auth.ts to configure authentication providers and options.

Modifying the Convex Schema

Edit convex/schema.ts to add or modify tables. Convex will automatically sync your schema changes.

Styling

The template uses Tailwind CSS v4. Customize your theme in src/app.css.

๐Ÿงช Type-Safe Error Handling

This boilerplate uses neverthrow for type-safe error handling:

import { ok, err } from '$lib/utils/result';

function divide(a: number, b: number) {
  if (b === 0) {
    return err('Cannot divide by zero');
  }
  return ok(a / b);
}

const result = divide(10, 2);
result.match(
  (value) => console.log('Success:', value),
  (error) => console.error('Error:', error)
);

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

๐Ÿ“š Learn More

๐Ÿ’ฌ Support

If you have any questions or need help, please:

  • Open an issue on GitHub
  • Check out the documentation links above
  • Join the respective community Discord servers

Built with โค๏ธ using modern web technologies

Top categories

Loading Svelte Themes