/spree-commerce:spree-headless-storefrontfrom spree-commerce
Builds and customizes Spree's official headless Next.js storefront (Next.js 16, React 19, Tailwind CSS 4, TypeScript 5) with server-only auth, MeiliSearch faceted catalog, one-page checkout, multi-region routing, GA4/JSON-LD SEO, and Vercel/Docker deployment.
Ships in spree-commerce. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Fetch live docs:
| Repo | Role |
|---|---|
spree/spree-starter | Rails backend application |
spree/storefront | Next.js headless storefront |
The storefront talks to the backend exclusively over API v3 (Store API).
| Layer | Tech |
|---|---|
| Framework | Next.js 16 (App Router, Server Actions, Turbopack) |
| UI runtime | React 19 (Server Components + Client Components) |
| Styling | Tailwind CSS 4 |
| Type system | TypeScript 5 |
| API client | @spree/sdk with Zod schemas |
| Search | MeiliSearch faceted search |
| Auth | Server-only — httpOnly JWT cookies + publishable key |
| Payments | Stripe Elements / Apple Pay / Google Pay / Link / Klarna / Affirm / SEPA |
| Analytics | GA4, JSON-LD, OpenGraph |
| Error tracking | Sentry |
| Deploy | Vercel (recommended) or Docker |
pk_…) from adminstorefront/
├── app/
│ ├── (storefront)/ # public pages (App Router groups)
│ │ ├── [region]/[locale]/
│ │ │ ├── products/
│ │ │ ├── cart/
│ │ │ └── checkout/
│ │ └── account/
│ ├── api/ # Route Handlers for webhooks etc.
│ ├── layout.tsx
│ └── page.tsx
├── components/
│ ├── ui/ # Tailwind-styled primitives
│ ├── product/
│ ├── cart/
│ └── checkout/
├── lib/
│ ├── spree.server.ts # admin/auth client — never imported client-side
│ ├── spree.public.ts # publishable-key client
│ ├── auth.ts # Server Action helpers for sign in/out
│ └── meilisearch.ts
├── public/
├── tailwind.config.ts
├── next.config.ts
└── package.json
pk_…) is the only Spree credential that may reach the browser.order_token also in httpOnly cookie.// app/api/auth/sign-in/route.ts (Route Handler)
import { cookies } from 'next/headers';
import { spreePublic } from '@/lib/spree.public';
export async function POST(req: Request) {
const { email, password } = await req.json();
const { access_token, refresh_token, expires_in } = await spreePublic.auth.signIn({ email, password });
cookies().set('spree_jwt', access_token, {
httpOnly: true,
secure: true,
sameSite: 'lax',
maxAge: expires_in,
});
cookies().set('spree_refresh', refresh_token, { httpOnly: true, secure: true, sameSite: 'lax' });
return Response.json({ ok: true });
}
URLs follow /[region]/[locale]/...:
/us/en/products/classic-tee/de/de/produkte/classic-teeThe storefront resolves current_market from the URL, then passes it to the API so backend filters by market-allowed payment methods, shipping methods, prices.
The storefront's PLP (Product Listing Page) issues a MeiliSearch query (or hits a Spree API v3 endpoint that proxies to MeiliSearch — verify the live pattern). Facets: brand, color, size, price range, taxon. Typo-tolerant.
ord_…Implemented as one-page with progressive disclosure in the official storefront.
// app/(storefront)/cart/actions.ts
'use server';
import { cookies } from 'next/headers';
import { revalidatePath } from 'next/cache';
import { spreePublic } from '@/lib/spree.public';
export async function addToCart(variantId: string, quantity = 1) {
const orderToken = cookies().get('spree_cart_token')?.value;
const result = await spreePublic.cart.addItem({ variantId, quantity, orderToken });
if (!orderToken) {
cookies().set('spree_cart_token', result.token, { httpOnly: true, secure: true, sameSite: 'lax' });
}
revalidatePath('/cart');
return result;
}
next-sitemap or similarnext/scriptview_item, add_to_cart, begin_checkout, purchase — fired client-side after Server Action completiongit clone https://github.com/spree/storefront my-storefront
cd my-storefront
cp .env.example .env.local
# Set:
# SPREE_API_URL=http://localhost:4000 (your Spree backend)
# NEXT_PUBLIC_SPREE_PUBLISHABLE_KEY=pk_test_...
# MEILISEARCH_HOST=http://localhost:7700
# MEILISEARCH_PUBLIC_KEY=...
npm install
npm run dev # http://localhost:3000
The App Router structure makes customization file-system-based — add or replace files under app/. For shared layout changes, edit the relevant layout.tsx.
Override Tailwind tokens in tailwind.config.ts:
export default {
theme: {
extend: {
colors: {
brand: { 500: '#0066ff', 600: '#0052cc' }
},
fontFamily: {
display: ['"Inter Display"', 'sans-serif']
}
}
}
}
For Tailwind 4 specifically, prefer the @theme directive in CSS:
@import 'tailwindcss';
@theme {
--color-brand-500: oklch(0.6 0.2 250);
--font-display: 'Inter Display', sans-serif;
}
// app/(storefront)/[region]/[locale]/about/page.tsx
export default async function AboutPage({ params }: { params: Promise<{ region: string; locale: string }> }) {
const { locale } = await params;
return <main>About {locale}</main>;
}
Next.js 16 wraps params in a Promise — await it.
If you've added a Metafield or extension field on the backend:
const product = await spreePublic.products.find('prod_...', { expand: ['metafields'] });
const launchDate = product.metafields?.my_app?.launch_date;
Augment SDK types via types/spree.d.ts if you want type safety.
| Page | Strategy |
|---|---|
| Homepage | ISR — revalidate: 60 |
| Product detail | ISR — revalidate: 300 (5 min) |
| Cart | Dynamic — dynamic = 'force-dynamic' |
| Account | Dynamic |
| Order confirmation | Dynamic |
Vercel (recommended):
SPREE_API_URL, NEXT_PUBLIC_SPREE_PUBLISHABLE_KEY, MeiliSearch creds, Sentry DSN)npm run buildDocker:
Dockerfilespree.server.ts from a Client Component — Next.js's 'use server' enforcement is essential; opt into it.revalidatePath after Server Actions — stale UI.Always re-fetch the storefront repo's README before customizing — the codebase iterates rapidly with each Spree release.
What SKILL.md sets; muted values are Claude Code's defaults
22 skills in this plugin
/spree-admin-customizationCustomize the Spree v5 Admin Dashboard — Tailwind 4 + Hotwire/Turbo/Stimulus stack, the `Spree.admin.navigation` declarative API (v5.2+) for menu items, partial injection slots (`store_nav_partials`, `store_products_nav_partials`, `store_orders_nav_partials`, `settings_nav_partials`), the Admin SDK components + form builder, custom dashboard reports, the Page Builder for storefront editing, and theme management. Use when adding admin pages, injecting UI into existing screens, or building admin extensions./spree-api-v3Build with Spree's v3 APIs (v5.4+) — Store API at `/api/v3/store/*` (publishable key + per-user JWT, customer-facing) and Admin API at `/api/v3/admin/*` (per-user API keys + OAuth2 Doorkeeper, admin/operations). Covers the flat-JSON Stripe-like envelope, `?expand=` / `?include=` parameters, prefixed IDs (`prod_…`, `ord_…`), OpenAPI 3.0 spec, rate limiting, idempotency, and migration from v2 JSON:API. Use when building API clients, SDKs, or extending API endpoints in a Spree v5.4+ deployment./spree-catalogBuild and customize Spree's catalog — Products with Variants and OptionTypes/OptionValues, Taxonomies and Taxons (nested set), Properties, Images via ActiveStorage, multi-currency Prices, the v5.3+ PriceList feature for customer/segment overrides, MeiliSearch faceted search (v5.4+), product archiving/activation, CSV import/export, and SEO. Use when modeling products, customizing the catalog UI, indexing search, or importing inventory.npx claudepluginhub orcaqubits/agentic-commerce-skills-plugins --plugin spree-commerceOther plugins' skills for the same job