svelte-ecommerce-starter Svelte Themes

Svelte Ecommerce Starter

Svelte ecommerce starter template with cart, product pages, and Tailwind CSS.

šŸ›ļø Svelte Ecommerce Starter

A production-ready SvelteKit e-commerce template with Stripe Checkout integration. Features a product catalog, shopping cart with persistent state, category filtering, and complete Stripe payment flow including webhooks.

Features

  • ⚔ SvelteKit 2 with TypeScript
  • šŸ’³ Stripe Checkout — one-time payments with webhook handling
  • šŸ›’ Shopping Cart — reactive store with add/remove/quantity controls
  • šŸ“¦ Product Catalog — filterable by category with detail pages
  • šŸŽØ Clean CSS — custom properties, responsive grid, no framework dependency
  • šŸ”” Webhook Handler — verify & process Stripe events
  • šŸ“± Responsive — mobile-first design

Quick Start

# Clone
git clone https://github.com/kszongic/svelte-ecommerce-starter.git
cd svelte-ecommerce-starter

# Install
npm install

# Configure
cp .env.example .env
# Add your Stripe keys to .env

# Dev
npm run dev

Environment Variables

Variable Description
STRIPE_SECRET_KEY Stripe secret key
STRIPE_WEBHOOK_SECRET Stripe webhook signing secret
PUBLIC_STRIPE_PUBLISHABLE_KEY Stripe publishable key
PUBLIC_SITE_URL Your site URL (for redirects)

Project Structure

src/
ā”œā”€ā”€ lib/
│   ā”œā”€ā”€ components/    # Navbar, ProductCard, Footer
│   ā”œā”€ā”€ data/          # Product data & helpers
│   ā”œā”€ā”€ stores/        # Cart store (Svelte stores)
│   └── stripe.ts      # Stripe server client
ā”œā”€ā”€ routes/
│   ā”œā”€ā”€ +layout.svelte
│   ā”œā”€ā”€ +page.svelte          # Home (featured products)
│   ā”œā”€ā”€ products/
│   │   ā”œā”€ā”€ +page.svelte      # All products + filters
│   │   └── [slug]/+page.svelte  # Product detail
│   ā”œā”€ā”€ cart/+page.svelte     # Cart + checkout trigger
│   ā”œā”€ā”€ checkout/+page.svelte # Success/cancel page
│   └── api/
│       ā”œā”€ā”€ checkout/+server.ts  # Create Stripe session
│       └── webhook/+server.ts   # Handle Stripe webhooks
└── app.css                   # Global styles

Stripe Webhooks (Local Dev)

stripe listen --forward-to localhost:5173/api/webhook

Customization

  • Products: Edit src/lib/data/products.ts
  • Styles: Modify CSS custom properties in src/app.css
  • Database: Replace the static product data with your preferred DB (Prisma, Drizzle, etc.)

Deploy

Works with any SvelteKit adapter — Vercel, Netlify, Cloudflare Pages, Node, etc.

npm run build
npm run preview

License

MIT

Top categories

Loading Svelte Themes