Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Agent Instructions
CLAUDE.md only imports this file — edit this one.
This is the Spree admin dashboard for this project — a Vite + React app. The
shell (routes, chrome, resource pages) ships in @spree/dashboard; this
project holds your customizations.
Full docs: https://spreecommerce.org/docs/developer/dashboard/overview
Running it
spree dev, run from the project root (../..), starts this app's dev server
together with the Spree API — don't start a second copy with pnpm dev. The
Spree API itself is only ever run through the Spree CLI; see the project
root's AGENTS.md.
Imports
Import from @spree/dashboard — it re-exports the framework and the design
system, so there is no need to work out which package an export lives in.
import { defineDashboardPlugin, useStore, Button, ResourceTable } from '@spree/dashboard'
@spree/dashboard-core and @spree/dashboard-ui stay importable for the few
components that exist in both: the design system's takes data as props, the
framework's fetches its own. The facade gives you the framework's.
Where code goes
Organized by kind, one file per resource — the same layout @spree/dashboard
uses internally.
| Directory | Holds | Naming |
|---|---|---|
src/plugins.ts |
Registrations only: nav, routes, slots, tables | one file |
src/pages/ |
One screen each | brands.tsx |
src/hooks/ |
Admin API wrappers | use-brands.ts |
src/tables/ |
defineTable calls |
brands.tsx |
src/schemas/ |
Zod schema + FormValues |
brand.ts |
src/slots/ |
Widgets injected into built-in pages | product-brand-card.tsx |
src/locales/ |
Your admin.* translation keys |
en.json |
Adding a resource touches one file in each directory. Keep plugins.ts a map
of what exists, not an implementation.
Rules
- The Admin API is the only data source. Never reach into the Rails app or import server-rendered HTML. A missing endpoint is added to the API first.
- Wrap API calls in a hook. Components never call
adminClientdirectly. - Query keys are store-scoped. Build them with
useResourceKey; a bare['brands']key leaks one store's data into another after a store switch. - Writes go through
useResourceMutation. It shows a toast for network and server failures but not for 422 validation errors — catch those in the form's submit handler withmapSpreeErrorsToForm, which puts each message on its field. - Every visible string goes through i18next — page titles, column labels, buttons, empty states, toasts. Never hardcode English in JSX or in a table definition. Add each new key to every locale file the project ships.
- Schemas hold canonical values, never labels. Build
{ value, label }pairs at render time so labels stay translatable. - Never embed an SDK entity type in a form-values type. React Hook Form walks every nested key and the SDK's object graph overflows the TypeScript compiler.
- A sortable or filterable column must be allowlisted for Ransack on the
model, or the request fails at runtime. That change belongs to the Spree API
in
../../server/— follow../../server/AGENTS.md. - Destructive actions that fire straight from a click need a confirm —
useConfirm()withvariant: 'destructive'. - Prefer icons from
@spree/dashboard-ui/icons, the dashboard's own icon set, over importinglucide-reactdirectly.
Checks
Run these with the project's package manager (pnpm, npm run or yarn):
pnpm typecheck
pnpm lint
pnpm test # unit tests (Vitest, Node environment)
pnpm build
Test the logic between the UI and the API — query keys, payload mapping, permission predicates. Do not write tests that render a component to assert its markup; that tests React. Use pnpm test:e2e when a browser is genuinely needed.