A complete, production-ready SaaS starter template featuring:
ā” Quick Start: Skip to installation | š Learn More: Architecture docs | šÆ Reuse Pattern: Integration reference
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:
git clone <your-repo-url>
cd claude-stripe-svelte
pnpm install
cp .env.example .env
Edit .env and fill in your keys:
Go to your Supabase project's SQL Editor and run the migration:
-- Copy and paste contents of supabase/migrations/00001_subscriptions_schema.sql
.env file# In a separate terminal
stripe listen --forward-to localhost:5173/api/webhooks/stripe
Copy the webhook signing secret to your .env file.
pnpm dev
Visit http://localhost:5173
āāā 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
Edit CSS variables in src/app.css:
:root {
--primary: 221.2 83.2% 53.3%; /* Your brand color */
/* ... other variables */
}
// +page.server.ts
import { redirect } from '@sveltejs/kit';
export const load = async ({ locals: { user } }) => {
if (!user) throw redirect(303, '/auth/login');
// Protected content here
};
import { getUserSubscription } from '$lib/supabase';
import { isSubscriptionActive } from '$lib/subscription';
const subscription = await getUserSubscription(supabase, userId);
const hasAccess = isSubscriptionActive(subscription);
# 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
Set these in your production environment:
.env.examplePUBLIC_APP_URL should be your production domainhttps://yourdomain.com/api/webhooks/stripecustomer.subscription.*, product.*, price.*Run migrations in your production Supabase project.
This project works with any SvelteKit-compatible platform:
See SvelteKit adapters for platform-specific setup.
For issues and questions:
ARCHITECTURE.md, STRIPE_SETUP.md)Contributions are welcome! This project serves as a reference implementation, but improvements are always appreciated.
Areas where contributions are especially welcome:
Please feel free to:
git checkout -b feature/amazing-feature)git push origin feature/amazing-feature)See ARCHITECTURE.md - Section 10 for planned features and improvements.
Short term:
Medium term:
If you find this project useful, consider giving it a ā on GitHub!
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
This project implements patterns and best practices recommended by: