Skip to content

armgit / spree

Public Imported from GitHub
0

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.

Add packages/dashboard-starter, the canonical dashboard host template

Damian Legawiec7c66d957f230
diff --git a/packages/dashboard-starter/.env.example b/packages/dashboard-starter/.env.example
new file mode 100644
index 0000000000..9523a1f5eb
--- /dev/null
+++ b/packages/dashboard-starter/.env.example
@@ -0,0 +1,4 @@
+# URL of your Spree API server. No credentials belong in this file —
+# admins sign in with email/password in the dashboard itself, and every
+# VITE_-prefixed value is compiled into the client bundle.
+VITE_SPREE_API_URL=http://localhost:3000
diff --git a/packages/dashboard-starter/.gitignore b/packages/dashboard-starter/.gitignore
new file mode 100644
index 0000000000..c2458765e8
--- /dev/null
+++ b/packages/dashboard-starter/.gitignore
@@ -0,0 +1,5 @@
+node_modules/
+dist/
+.env.local
+.env.*.local
+*.log
diff --git a/packages/dashboard-starter/README.md b/packages/dashboard-starter/README.md
new file mode 100644
index 0000000000..af83b19ce5
--- /dev/null
+++ b/packages/dashboard-starter/README.md
@@ -0,0 +1,36 @@
+# Spree Dashboard Starter
+
+The host app for the [Spree React Dashboard](https://docs.spreecommerce.org/developer/dashboard/overview) — the admin for your Spree store. `@spree/dashboard` is the actual app shell (routes, chrome, resource pages); this project is your customization point: plugins, your own pages, theming, and deployment config.
+
+> **Monorepo note.** The canonical source of this template lives at `packages/dashboard-starter` in [spree/spree](https://github.com/spree/spree), where its Spree dependencies resolve via the pnpm workspace and `@spree/dashboard-plugin-example` is installed as a devDependency — booting it here doubles as the end-to-end test for the plugin pipeline. A release job syncs it to the `spree/dashboard-starter` template repo with published package versions, which is what `create-spree-app` and `spree add dashboard` clone.
+
+## Develop
+
+```bash
+pnpm install
+cp .env.example .env.local # point VITE_SPREE_API_URL at your Spree API
+pnpm dev # http://localhost:5173
+```
+
+Sign in with an admin account — authentication is interactive (JWT + refresh cookie). No API keys belong in `.env.local`: every `VITE_`-prefixed value is compiled into the client bundle.
+
+## Install a dashboard plugin
+
+```bash
+pnpm add @acme/reviews-plugin
+# restart the dev server
+```
+
+That's the whole install. `spreeDashboardPlugin()` (see `vite.config.ts`) discovers any dependency carrying the `spree.dashboard.plugin` marker, activates it through the `virtual:spree-dashboard-plugins` module imported in `src/main.tsx`, and wires its Tailwind classes.
+
+## Customize
+
+`src/plugins.ts` is yours — register nav entries, routes, slot widgets, and table columns with `defineDashboardPlugin` from `@spree/dashboard-core`. Same API the distributed plugins use; see the [customization quickstart](https://docs.spreecommerce.org/developer/dashboard/customization/quickstart).
+
+## Build & deploy
+
+```bash
+pnpm build # static assets in dist/
+```
+
+Deploy `dist/` to any static host. Set `VITE_SPREE_API_URL` to your production API at build time, and configure the API's CORS/cookie settings for the dashboard origin.
diff --git a/packages/dashboard-starter/biome.json b/packages/dashboard-starter/biome.json
new file mode 100644
index 0000000000..9e3688583f
--- /dev/null
+++ b/packages/dashboard-starter/biome.json
@@ -0,0 +1,8 @@
+{
+ "$schema": "https://biomejs.dev/schemas/2.4.13/schema.json",
+ "root": false,
+ "extends": ["../../biome.json"],
+ "files": {
+ "includes": ["src/**", "*.ts", "index.html", "!src/**/*.css"]
+ }
+}
diff --git a/packages/dashboard-starter/index.html b/packages/dashboard-starter/index.html
new file mode 100644
index 0000000000..dec13fbb57
--- /dev/null
+++ b/packages/dashboard-starter/index.html
@@ -0,0 +1,27 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <title>Spree Admin</title>
+ </head>
+ <body>
+ <script>
+ (() => {
+ try {
+ const stored = localStorage.getItem('spree-admin-theme');
+ const mode = stored === 'light' || stored === 'dark' ? stored : 'system';
+ const dark =
+ mode === 'dark' ||
+ (mode === 'system' && window.matchMedia('(prefers-color-scheme: dark)').matches);
+ if (dark) document.documentElement.classList.add('dark');
+ document.documentElement.style.colorScheme = dark ? 'dark' : 'light';
+ } catch (_) {
+ /* localStorage unavailable */
+ }
+ })();
+ </script>
+ <div id="root"></div>
+ <script type="module" src="/src/main.tsx"></script>
+ </body>
+</html>
diff --git a/packages/dashboard-starter/package.json b/packages/dashboard-starter/package.json
new file mode 100644
index 0000000000..481664c126
--- /dev/null
+++ b/packages/dashboard-starter/package.json
@@ -0,0 +1,32 @@
+{
+ "name": "@spree/dashboard-starter",
+ "private": true,
+ "license": "MIT",
+ "version": "0.0.0",
+ "type": "module",
+ "scripts": {
+ "dev": "vite",
+ "build": "vite build",
+ "preview": "vite preview",
+ "typecheck": "tsc --noEmit",
+ "lint": "biome check .",
+ "lint:fix": "biome check --fix ."
+ },
+ "dependencies": {
+ "@spree/admin-sdk": "workspace:^",
+ "@spree/dashboard": "workspace:^",
+ "@spree/dashboard-core": "workspace:^",
+ "@spree/dashboard-ui": "workspace:^",
+ "react": "^19.2.6",
+ "react-dom": "^19.2.6"
+ },
+ "devDependencies": {
+ "@biomejs/biome": "^2.4.14",
+ "@spree/dashboard-plugin-example": "workspace:^",
+ "@types/react": "^19.2.14",
+ "@types/react-dom": "^19.2.3",
+ "@vitejs/plugin-react": "^6.0.1",
+ "typescript": "~6.0.3",
+ "vite": "^8.0.16"
+ }
+}
diff --git a/packages/dashboard-starter/src/main.tsx b/packages/dashboard-starter/src/main.tsx
new file mode 100644
index 0000000000..b22edb14b6
--- /dev/null
+++ b/packages/dashboard-starter/src/main.tsx
@@ -0,0 +1,14 @@
+// The shell module runs the i18n/nav/search bootstrap on import — it must
+// execute before the plugin imports below so plugins can call i18n.t at
+// module load. (Side-effect imports are ordering barriers.)
+import { Dashboard } from '@spree/dashboard'
+import { createRoot } from 'react-dom/client'
+// Activate installed dashboard plugins — synthesized by spreeDashboardPlugin()
+// from your package.json deps. `pnpm add <plugin>` + dev-server restart is the
+// whole install; this line never changes.
+import 'virtual:spree-dashboard-plugins'
+// Your own customizations (nav entries, routes, slot widgets, table columns).
+import './plugins'
+import './styles.css'
+
+createRoot(document.getElementById('root')!).render(<Dashboard />)
diff --git a/packages/dashboard-starter/src/plugins.ts b/packages/dashboard-starter/src/plugins.ts
new file mode 100644
index 0000000000..ff7e0e3c49
--- /dev/null
+++ b/packages/dashboard-starter/src/plugins.ts
@@ -0,0 +1,19 @@
+// Dashboard customizations for this store.
+//
+// Register nav entries, routes, slot widgets, and table columns against the
+// shared registries — the same API distributed plugins use. Imported once
+// from main.tsx, before the dashboard renders.
+//
+// Example:
+//
+// import { defineDashboardPlugin } from '@spree/dashboard-core'
+// import { AnalyticsPage } from './pages/analytics'
+//
+// defineDashboardPlugin({
+// nav: [{ key: 'analytics', label: 'Analytics', path: '/analytics', position: 60 }],
+// routes: [{ key: 'analytics', path: '/analytics', component: AnalyticsPage }],
+// })
+//
+// Docs: https://docs.spreecommerce.org/developer/dashboard/customization/quickstart
+
+export {}
diff --git a/packages/dashboard-starter/src/styles.css b/packages/dashboard-starter/src/styles.css
new file mode 100644
index 0000000000..81db1b0ec5
--- /dev/null
+++ b/packages/dashboard-starter/src/styles.css
@@ -0,0 +1,8 @@
+/* CSS entry. The Spree stylesheet chain provides Tailwind v4 layers, design
+ * tokens, and base styles; `spreeDashboardPlugin()` appends `@source`
+ * directives here at build time so Tailwind scans every Spree dashboard
+ * package and installed plugin for class usage.
+ *
+ * Add your own styles below the import. */
+
+@import "@spree/dashboard/styles.css";
diff --git a/packages/dashboard-starter/tsconfig.json b/packages/dashboard-starter/tsconfig.json
new file mode 100644
index 0000000000..56631abbfd
--- /dev/null
+++ b/packages/dashboard-starter/tsconfig.json
@@ -0,0 +1,20 @@
+{
+ "compilerOptions": {
+ "target": "ES2022",
+ "ignoreDeprecations": "6.0",
+ "useDefineForClassFields": true,
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
+ "module": "ESNext",
+ "types": ["vite/client"],
+ "skipLibCheck": true,
+ "moduleResolution": "bundler",
+ "verbatimModuleSyntax": true,
+ "moduleDetection": "force",
+ "noEmit": true,
+ "jsx": "react-jsx",
+ "strict": true,
+ "noFallthroughCasesInSwitch": true,
+ "noUncheckedSideEffectImports": true
+ },
+ "include": ["src"]
+}
diff --git a/packages/dashboard-starter/vite.config.ts b/packages/dashboard-starter/vite.config.ts
new file mode 100644
index 0000000000..0806465d42
--- /dev/null
+++ b/packages/dashboard-starter/vite.config.ts
@@ -0,0 +1,28 @@
+import { spreeDashboardPlugin } from '@spree/dashboard/vite'
+import react from '@vitejs/plugin-react'
+import { defineConfig } from 'vite'
+
+export default defineConfig({
+ // spreeDashboardPlugin bundles Tailwind, injects @source directives for
+ // every Spree dashboard package, auto-discovers installed dashboard
+ // plugins (package.json deps carrying the `spree.dashboard.plugin`
+ // marker), and serves the `virtual:spree-dashboard-plugins` module that
+ // src/main.tsx imports to activate them. No TanStack Router plugin needed:
+ // the route tree ships pre-generated inside @spree/dashboard.
+ plugins: [spreeDashboardPlugin(), react()],
+ // Proxy /api to the Rails server so the SPA is same-origin with the API in
+ // dev — keeps the refresh-token cookie working under SameSite=Lax without
+ // HTTPS. /rails covers Active Storage's Disk-service presigned URLs.
+ server: {
+ proxy: {
+ '/api': {
+ target: process.env.VITE_SPREE_API_URL || 'http://localhost:3000',
+ changeOrigin: true,
+ },
+ '/rails': {
+ target: process.env.VITE_SPREE_API_URL || 'http://localhost:3000',
+ changeOrigin: true,
+ },
+ },
+ },
+})
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 2b8e83d679..9271e48f33 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -442,6 +442,49 @@ importers:
specifier: ^8.0.16
+ packages/dashboard-starter:
+ dependencies:
+ '@spree/admin-sdk':
+ specifier: workspace:^
+ version: link:../admin-sdk
+ '@spree/dashboard':
+ specifier: workspace:^
+ version: link:../dashboard
+ '@spree/dashboard-core':
+ specifier: workspace:^
+ version: link:../dashboard-core
+ '@spree/dashboard-ui':
+ specifier: workspace:^
+ version: link:../dashboard-ui
+ react:
+ specifier: ^19.2.6
+ version: 19.2.6
+ react-dom:
+ specifier: ^19.2.6
+ version: 19.2.6([email protected])
+ devDependencies:
+ '@biomejs/biome':
+ specifier: ^2.4.14
+ version: 2.4.14
+ '@spree/dashboard-plugin-example':
+ specifier: workspace:^
+ version: link:../dashboard-plugin-example
+ '@types/react':
+ specifier: ^19.2.14
+ version: 19.2.14
+ '@types/react-dom':
+ specifier: ^19.2.3
+ version: 19.2.3(@types/[email protected])
+ '@vitejs/plugin-react':
+ specifier: ^6.0.1
+ typescript:
+ specifier: ~6.0.3
+ version: 6.0.3
+ vite:
+ specifier: ^8.0.16
+
packages/dashboard-ui:
dependencies:
'@base-ui/react':