claude-stripe-svelte Svelte Themes

Claude Stripe Svelte

Production-ready SvelteKit SaaS starter with Stripe subscriptions, idempotent fulfillment, Supabase auth/database, and shadcn-svelte UI. Follows Stripe's official best practices.

SvelteKit SaaS Starter with Stripe & Supabase

A complete, production-ready SaaS starter template featuring:

  • šŸ” Supabase Authentication - Secure email/password auth with email verification
  • šŸ’³ Stripe Subscriptions - Complete subscription lifecycle with webhooks
  • šŸŽØ shadcn-svelte UI - Beautiful, accessible components built with Tailwind CSS v4
  • ⚔ SvelteKit + Svelte 5 - Modern framework with runes syntax
  • šŸ“Š Subscription Dashboard - User dashboard with subscription management
  • šŸ”’ Row Level Security - Database security with Supabase RLS
  • šŸ’Ŗ TypeScript - Full type safety throughout

⚔ Quick Start: Skip to installation | šŸ“– Learn More: Architecture docs | šŸŽÆ Reuse Pattern: Integration reference


Why Use This Starter?

This project implements Stripe's official fulfillment best practices with:

āœ… Idempotent fulfillment - Safe to call multiple times, prevents duplicate actions āœ… Dual-trigger pattern - Webhooks + Success page for instant UX + reliability āœ… Async payment support - ACH, bank transfers handled automatically āœ… Production-tested patterns - Based on real-world SaaS implementations āœ… Comprehensive documentation - 40+ pages covering architecture & decisions

Perfect for:

  • SaaS MVPs that need subscriptions fast
  • Learning production-ready Stripe integration
  • Reference implementation for your own projects

Features

Authentication

  • Email/password authentication with Supabase
  • Email verification flow
  • Protected routes and session management
  • SSR-compatible auth with proper cookie handling

Subscription Management

  • Browse pricing plans
  • Subscribe via Stripe Checkout
  • Idempotent fulfillment system - Production-ready, prevents double-processing
  • Dual-trigger fulfillment - Webhooks + Success page for instant UX
  • Async payment support - ACH, bank transfers handled automatically
  • Automatic subscription sync with webhooks
  • Customer portal for subscription management
  • Trial period support
  • Subscription status tracking (active, trialing, past_due, canceled, etc.)
  • Fulfillment tracking - Complete audit trail in database

Database

  • PostgreSQL database via Supabase
  • Automatic webhook data sync
  • Row Level Security (RLS) policies
  • Database schema migrations

UI/UX

  • Responsive design
  • Light/dark theme support (customizable)
  • Clean, modern interface
  • Accessible components following shadcn design system

Quick Start

Prerequisites

Installation

  1. Clone and install dependencies:
git clone <your-repo-url>
cd claude-stripe-svelte
pnpm install
  1. Set up environment variables:
cp .env.example .env

Edit .env and fill in your keys:

  1. Set up the database:

Go to your Supabase project's SQL Editor and run the migration:

-- Copy and paste contents of supabase/migrations/00001_subscriptions_schema.sql
  1. Create products in Stripe:
  1. Set up webhooks for local development:
# In a separate terminal
stripe listen --forward-to localhost:5173/api/webhooks/stripe

Copy the webhook signing secret to your .env file.

  1. Start the development server:
pnpm dev

Visit http://localhost:5173

Project Structure

ā”œā”€ā”€ src/
│   ā”œā”€ā”€ lib/
│   │   ā”œā”€ā”€ components/ui/          # shadcn-svelte components
│   │   ā”œā”€ā”€ stripe.server.ts        # Stripe SDK (server-only)
│   │   ā”œā”€ā”€ supabase.ts             # Database helpers
│   │   ā”œā”€ā”€ subscription.ts         # Subscription utilities
│   │   └── utils.ts                # Utilities (cn, etc.)
│   ā”œā”€ā”€ routes/
│   │   ā”œā”€ā”€ api/
│   │   │   ā”œā”€ā”€ stripe/             # Stripe API endpoints
│   │   │   └── webhooks/stripe/    # Stripe webhook handler
│   │   ā”œā”€ā”€ auth/                   # Auth pages (login, signup, etc.)
│   │   ā”œā”€ā”€ dashboard/              # Protected dashboard
│   │   ā”œā”€ā”€ pricing/                # Public pricing page
│   │   └── +page.svelte            # Landing page
│   ā”œā”€ā”€ app.css                     # Global styles + Tailwind
│   ā”œā”€ā”€ app.d.ts                    # TypeScript definitions
│   └── hooks.server.ts             # Server hooks (Supabase SSR)
ā”œā”€ā”€ supabase/
│   ā”œā”€ā”€ migrations/                 # Database migrations
│   └── README.md                   # Database setup guide
ā”œā”€ā”€ .env.example                    # Environment variables template
ā”œā”€ā”€ ARCHITECTURE.md                 # Architecture & design decisions
ā”œā”€ā”€ STRIPE_SETUP.md                 # Stripe setup guide
ā”œā”€ā”€ FULFILLMENT_GUIDE.md            # Fulfillment system guide
└── CLAUDE.md                       # Technical documentation

Documentation

Getting Started

  • README.md - You are here! Quick start guide

Understanding the Architecture

Implementation Guides

For AI Development

  • CLAUDE.md - Technical documentation for Claude Code instances

Common Tasks

Add a New Subscription Plan

  1. Create product in Stripe Dashboard
  2. Product will auto-sync via webhook
  3. Plan automatically appears on pricing page

Customize UI Theme

Edit CSS variables in src/app.css:

:root {
  --primary: 221.2 83.2% 53.3%;  /* Your brand color */
  /* ... other variables */
}

Add Protected Content

// +page.server.ts
import { redirect } from '@sveltejs/kit';

export const load = async ({ locals: { user } }) => {
  if (!user) throw redirect(303, '/auth/login');
  // Protected content here
};

Check Subscription Status

import { getUserSubscription } from '$lib/supabase';
import { isSubscriptionActive } from '$lib/subscription';

const subscription = await getUserSubscription(supabase, userId);
const hasAccess = isSubscriptionActive(subscription);

Development Commands

# Development
pnpm dev              # Start dev server
pnpm build            # Build for production
pnpm preview          # Preview production build

# Code Quality
pnpm check            # Type check
pnpm format           # Format with Prettier
pnpm lint             # Lint with ESLint

Deployment

Environment Variables

Set these in your production environment:

  • All variables from .env.example
  • PUBLIC_APP_URL should be your production domain

Webhook Setup

  1. Go to Stripe Dashboard > Webhooks
  2. Add endpoint: https://yourdomain.com/api/webhooks/stripe
  3. Select events: customer.subscription.*, product.*, price.*
  4. Copy signing secret to production env vars

Database

Run migrations in your production Supabase project.

Deployment Platforms

This project works with any SvelteKit-compatible platform:

  • Vercel
  • Netlify
  • Cloudflare Pages
  • Your own server

See SvelteKit adapters for platform-specific setup.

Tech Stack

Security

  • āœ… Row Level Security (RLS) enabled on all tables
  • āœ… Webhook signature verification
  • āœ… Server-side API key handling
  • āœ… CSRF protection via SvelteKit
  • āœ… Secure session management
  • āœ… Email verification for new accounts

Support

For issues and questions:

Contributing

Contributions are welcome! This project serves as a reference implementation, but improvements are always appreciated.

Areas where contributions are especially welcome:

  • Additional payment methods (PayPal, crypto, etc.)
  • Email notification templates
  • More comprehensive test suite
  • Additional UI components
  • Internationalization (i18n)
  • Documentation improvements

Please feel free to:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Roadmap

See ARCHITECTURE.md - Section 10 for planned features and improvements.

Short term:

  • Email notifications system
  • More shadcn-svelte components
  • Usage-based billing examples

Medium term:

  • Multi-subscription support
  • Team/organization features
  • Admin dashboard

Star History

If you find this project useful, consider giving it a ⭐ on GitHub!

License

MIT License - see LICENSE file for details

This project is free to use for personal and commercial projects. Attribution is appreciated but not required.


Built with ā¤ļø using SvelteKit, Stripe, and Supabase

Created by @anuarhdz with assistance from Claude Code


Acknowledgments

This project implements patterns and best practices recommended by:

Top categories

Loading Svelte Themes