spree/storefront
Tentang
Open-source Next.js eCommerce storefront for @spree. DTC & B2B, Stripe/Adyen/PayPal payments, multi-region, one page checkout. MIT license.
Bisnis dan keuanganYang dapat Anda lakukan
- Product Catalog - Browse, search, filter products by categories, and use faceted navigation. Optional Meilisearch integration available
- Product Details - View product information with variant selection and media
- Shopping Cart - Add, update, and remove items with server-side state
- One-page Checkout - Guest visitors and signed-in users supported, multi-shipments supported natively, Coupon Codes, Gift Cards, Store Credit
Pertumbuhan bintang terukur
- dalam 24 jam
- 0
- dalam 7 hari
- +1
- dalam 15 hari
- +3
- dalam 1 bulan
- Mengumpulkan riwayat
Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.
README.md
AsliSpree Commerce Storefront
A production-ready, headless ecommerce storefront for Spree Commerce, built with Next.js 16, React 19, and the Spree REST API. Open source (MIT) and free to customize.
Live Demo | Quickstart Docs | TypeScript SDK
Why This Storefront
TypeScript SDK. @spree/sdk is an official typed client for every Store API endpoint (OpenAPI 3.0 documented). Autocomplete and type safety in your editor, no codegen step to maintain.
DTC and B2B out of the box run both DTC and B2B (wholesale portal) from a single instance powered by Spree Channels, with exclusive customer group pricing and product gating.
Multi-region out of the box. Country, currency, and language switching via URL segments (/us/en/, /de/de/, /uk/en/), powered by Spree Markets. Distinct selling regions bundling geography, currency, and locale in a single store.
One-page checkout. Guest and authenticated users, multi-shipment, coupon codes, gift cards, and store credit. Stripe, PayPal, and Adyen via Payment Sessions. Card data never touches your server. Swap providers easily.
Transactional emails. Order confirmation, shipping notification, password reset. Built with react-email, sent via Resend, triggered by Spree webhooks.
Readable by AI agents. Shopping agents and AI search read the store without scraping it: /llms.txt indexes the shop, every product and category page is also served as Markdown, and pages carry schema.org structured data with prices and stock for each variant. See AI Agents.
MIT licensed. Open source and free to use.
Performance
The live demo at demo.spreecommerce.org scores 98/100 on desktop and 88/100 on mobile for Performance on Google's Lighthouse audit, with five language versions served from the same deployment.
| Lighthouse metric | Mobile | Desktop |
|---|---|---|
| Performance | 88 | 98 |
| Accessibility | 100 | 100 |
| Best Practices | 100 | 100 |
| SEO | 100 | 100 |
No external performance plugins. No edge-side rendering hacks. The architecture is Next.js 16 App Router with React 19 Server Components, server-side data fetching via @spree/sdk, and Tailwind CSS 4.
Run the audit yourself on PageSpeed Insights
Features
| Feature | Details |
|---|---|
| Product Catalog | Browse, search, filter products by categories, and use faceted navigation. Optional Meilisearch integration available |
| Product Details | View product information with variant selection and media |
| Shopping Cart | Add, update, and remove items with server-side state |
| One-page Checkout | Guest visitors and signed-in users supported, multi-shipments supported natively, Coupon Codes, Gift Cards, Store Credit |
| Stripe/Adyen/PayPal payments | native Stripe/Adyen/Paypal payment support with their SDKs, PCI-Compliant, 3DS-Secure, use Credit Cards, Apple Pay, Google Pay, Klarna, Affirm, SEPA payments |
| Customer Account | Full account management: Profile management, Order history with detailed order view, Address book (create, edit, delete), Gift Cards and Store Credit, Saved payment methods |
| Wholesale portal | Storefront gating, per-customer pricing and product availability, account approval workflows |
| Multi-Region Support | Country, currency, and language switching via URL segments, powered by Spree Markets |
| Responsive Design | Mobile-first Tailwind CSS styling |
| Google Tag Manager and Google Analytics 4 Ecommerce events | tracking supported natively |
| Store Policies | Policy pages fetched from Spree API, with consent checkboxes on registration and guest checkout |
| SEO-ready | meta tags, JSON-LD, OpenGraph — all built in |
| AI agent-ready | /llms.txt, Markdown versions of product and category pages, and schema.org JSON-LD with per-variant offers. See AI Agents |
| Error Tracking | Sentry integration for both server-side and client-side error monitoring with source maps |
Technology
| Technology | Role |
|---|---|
| Next.js 16 | App Router, Server Actions, Turbopack |
| React 19 | Latest React with improved Server Components |
| Tailwind CSS 4 | Utility-first styling |
| TypeScript | Full type safety |
| Sentry | Error tracking and performance monitoring with source maps |
| @spree/sdk | Official Spree Commerce SDK |
Architecture
This starter follows a server-first pattern:
- Server-First Architecture - All API calls happen server-side using Next.js Server Actions
- httpOnly Cookies - Auth tokens and cart tokens are stored securely
- No Client-Side API Calls - The Spree API key is never exposed to the browser
- Cache Revalidation - Uses Next.js cache tags for efficient updates
Browser → Server Action → @spree/sdk → Spree API
(with httpOnly cookies via src/lib/spree helpers)
Project structure, the src/lib/data/ server actions, and the JWT-in-httpOnly-cookie auth flow are covered in the Architecture guide.
Getting Started
Prerequisites
- Node.js 20+ (required for Next.js 16)
- A running Spree Commerce 6.0.6+
Installation
Recommended — scaffold a full project. create-spree-app sets up a Spree backend, this storefront, and the spree CLI together, with the storefront's environment wired to the backend automatically:
npx create-spree-app my-store
The storefront lands in apps/storefront/.
Standalone. To run the storefront on its own against an existing Spree backend, or to work on this repo directly
Install dependencies:
pnpm installCopy the environment file and configure:
cp .env.local.example .env.localUpdate
.env.localwith your Spree API credentials:SPREE_API_URL=http://localhost:3000 SPREE_PUBLISHABLE_KEY=your_publishable_api_key_here
Note: These are server-side only variables (no
NEXT_PUBLIC_prefix needed).
These two are all you need to boot. Optional variables cover analytics, error tracking, the wholesale portal, transactional emails, and SEO — see the Environment Variables reference, or copy .env.example, which lists them all with inline comments.
Development
pnpm run dev
Open http://localhost:3001 in your browser.
Working against a local SDK
To develop against unreleased Store API features, point the storefront at a @spree/sdk build from a Spree monorepo checkout instead of the published package:
SPREE_SDK_PATH=/path/to/spree/packages/sdk pnpm install --no-frozen-lockfile
.pnpmfile.cjs redirects the dependency at the local path only when SPREE_SDK_PATH is set, so the default install is unaffected and nothing local ever reaches package.json. Two things follow from it copying the package rather than symlinking it (this project pins module resolution to its own directory, so a symlink outside it would not resolve): build the SDK first (pnpm build in the monorepo), and re-run the install above after each rebuild to pick the new build up. The install also rewrites pnpm-lock.yaml with the local path — do not commit that change.
From a Spree monorepo worktree, pnpm wt:storefront does all of this for you, including the API URL and publishable key.
HTTPS Development (Apple Pay / Google Pay)
Testing Apple Pay / Google Pay locally needs a public HTTPS URL (Stripe verifies the payment method domain from the internet). See Wallet Payments in Development for the Cloudflare Tunnel setup.
Production Build
pnpm run build
pnpm start
Testing
Unit and integration tests run through Vitest (pnpm test); end-to-end tests run through Playwright against a real Spree backend in Docker (pnpm run e2e:up && pnpm run test:e2e). See the Testing guide for the full E2E setup, Stripe test keys, CI, and running against your own backend.
Multi-Region
Multiple countries, currencies, and languages from one deployment via /{country}/{locale} URL segments and edge middleware. See the Multi-Region guide.
Customization
The storefront ships in your project — restyle with Tailwind CSS, swap components in src/components/, and adjust the server actions in src/lib/data/. See the Customization guide.
Transactional Emails
The storefront can render and send its own order, shipment, and account emails with react-email and Resend, driven by Spree webhooks. See the Transactional Emails guide.
Catalog Cache Revalidation
Product lists, search and product pages are cached for up to 10 minutes. To show catalog changes at once (for example, a product taken down, archived or set to draft leaving search), subscribe the webhook endpoint (/api/webhooks/spree, signed with SPREE_WEBHOOK_SECRET) to these events: product.created, product.updated, product.deleted, product.activated, product.approved, product.drafted and product.archived. You can use the same endpoint as for emails.
Store settings from Spree Admin → Settings → Store (name, SEO title and description, keywords, logo, social accounts and support email) are cached for up to an hour. Subscribe the same endpoint to store.updated to show changes at once.
AI Agents
Shoppers increasingly send an AI agent to look at a shop for them. The storefront gives agents and AI search engines the same catalog a browser gets, in formats that are cheap to read. It works out of the box; set NEXT_PUBLIC_SITE_URL so the links it publishes are absolute.
| What | Where | Details |
|---|---|---|
| Store index | /llms.txt |
The store's name and description, with links to the home page, products, search, collections, top-level categories, policies and sitemaps. Follows the llms.txt convention |
| Markdown pages | Any product or category URL plus .md, for example /us/en/products/trail-tee.md |
Name, price, original price, stock, variants with SKUs, description, categories and images, without page chrome or scripts. Category pages list their subcategories and the first page of products, each linked to its own Markdown page, and say how many products there are in all. The HTML page links to it with <link rel="alternate" type="text/markdown"> |
| Structured data | JSON-LD on every page | schema.org Product with one Offer per priced variant (SKU, price, availability), BreadcrumbList on product and category pages, ItemList on category and collection pages, WebSite with a SearchAction on the home page, and Organization site-wide |
| Sitemaps and robots | /robots.txt, /sitemap/*.xml |
Every product, category and collection page in each market, with account, cart and checkout pages kept out of crawling. Allow or block specific crawlers in src/app/robots.ts |
Agents see what a guest sees: prices and stock for the country and language in the URL, never a signed-in customer's prices or the wholesale portal. Store-provided text is escaped in the Markdown pages and in JSON-LD, so a product name or description cannot inject markup. Markdown responses name the HTML page as canonical in a Link header, which tells search engines to prefer the HTML page over the Markdown copy.
Working on the storefront with a coding agent? AGENTS.md holds the project's conventions and the Spree 6 patterns to follow.
Deployment
Deploy to Vercel, Docker (a multi-stage Dockerfile ships at the repo root), or any Node.js host. See the Deployment guide.
License
MIT
Jelajahi proyek terkait
Memuat…