A complete SvelteKit port of the Next.js grocery store with identical UI and flow.
grocery-store-cart) and survives page refreshesdefault for size)checkout.confirm() flow (NOT mock)@import "tailwindcss" syntaxsrc/
├── lib/
│ ├── components/
│ │ ├── TopBar.svelte # Promotional deals banner
│ │ ├── StoreHeader.svelte # Main header with cart
│ │ ├── StoreNavigation.svelte # Navigation menu
│ │ ├── HeroBanner.svelte # Hero carousel
│ │ └── StoreFooter.svelte # Footer
│ ├── stores/
│ │ └── cart.ts # Cart state management
│ └── constants.ts # Store config and products
├── routes/
│ ├── +layout.svelte # Root layout
│ ├── +page.svelte # Home page
│ ├── product/+page.svelte # Product details
│ ├── cart/+page.svelte # Shopping cart
│ ├── checkout/
│ │ ├── +page.svelte # Order confirmation
│ │ ├── stripe/+page.svelte # Stripe checkout
│ │ └── success/+page.svelte # Payment success
│ └── api/
│ ├── create-checkout-session/+server.ts
│ └── session-status/+server.ts
└── app.css # Global styles
Install dependencies:
npm install
Configure environment variables:
Create a .env file:
STRIPE_SECRET_KEY=sk_test_...
PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_...
Or use the default test key:
PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_51ShiIxLlwE3MW2ahqcf5GHv1wxm1JqfHXhwa4dCYBFPMpJQinJk2UvulkAcRHuvgrpUxrU4H5SgxgVDNdLkUjEKT008AdnSHev
Run development server:
npm run dev
Build for production:
npm run build
useContext hookwritable, derived, and $state runesapp/ directory with page.tsx filesroutes/ directory with +page.svelte filesapp/api/*/route.ts with NextResponse.json()routes/api/*/+server.ts with json() from @sveltejs/kituseRouter() and router.push()goto() from $app/navigation@stripe/react-stripe-js with React components@stripe/stripe-js directly with manual Elements mounting via onMount()framer-motion libraryfly, fade)$derived() rune (Svelte 5 style) instead of legacy $: syntax// Import
import { cartItems, cartCount, subtotal, addToCart, removeFromCart, updateQuantity, clearCart } from '$lib/stores/cart';
// Usage in components
$cartItems // Array of cart items
$cartCount // Total item count
$subtotal // Cart subtotal
addToCart(item) // Add item to cart
removeFromCart(id, size) // Remove item from cart
updateQuantity(id, quantity, size) // Update item quantity
clearCart() // Clear all items
/checkout/stripe/api/create-checkout-sessionstripe.confirmPayment() with real confirmation/checkout/success on success/api/session-status# Type checking
npm run check
# Type checking with watch mode
npm run check:watch
svelte-checkMIT