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.

Run the example plugin in dashboard dev mode behind VITE_EXAMPLE_PLUGIN

Damian Legawiec21a5a142fa81
diff --git a/docs/developer/dashboard/customization/routes.mdx b/docs/developer/dashboard/customization/routes.mdx
index aa7dc64481..ec4b97ad7f 100644
--- a/docs/developer/dashboard/customization/routes.mdx
+++ b/docs/developer/dashboard/customization/routes.mdx
@@ -104,12 +104,15 @@ Use TanStack Router's `<Link>`. The dashboard's link API expects a path template
```tsx
import { Link } from '@tanstack/react-router'
-<Link to={'/$storeId/reports/$reportId' as string} params={{ storeId, reportId }}>
+<Link
+ to={'/$storeId/reports/$reportId' as string}
+ params={{ storeId, reportId } as never}
+>
View report
</Link>
```
-The `as string` cast bypasses TanStack Router's static type-checking for the path (because custom routes aren't in the generated route tree). Params are passed as a keyed object — each key fills the matching `$name` token.
+The casts bypass TanStack Router's static type-checking (custom routes aren't in the generated route tree, so neither the path nor its params exist as types). Params are passed as a keyed object — each key fills the matching `$name` token.
## Order of operations
diff --git a/packages/dashboard-plugin-example/README.md b/packages/dashboard-plugin-example/README.md
index 85a5fc24c2..1130a97601 100644
--- a/packages/dashboard-plugin-example/README.md
+++ b/packages/dashboard-plugin-example/README.md
@@ -31,7 +31,14 @@ For the request layer pattern (`adminClient.request<T>` against custom endpoints
## Activate this plugin in the dashboard
-Add a side-effect import to your dashboard app's entry (`packages/dashboard/src/main.tsx` for the bundled dashboard, your own `main.tsx` for a custom admin app):
+In this monorepo, `@spree/dashboard` already wires the plugin up behind an env flag — no code changes needed:
+
+```bash
+cd packages/dashboard
+VITE_EXAMPLE_PLUGIN=true pnpm dev
+```
+
+In your own dashboard app, add a side-effect import to the entry (`packages/dashboard/src/main.tsx` for the bundled dashboard, your own `main.tsx` for a custom admin app):
```ts
import '@spree/dashboard-plugin-example'
diff --git a/packages/dashboard-plugin-example/src/index.tsx b/packages/dashboard-plugin-example/src/index.tsx
index af2ab16eb8..df1fac73e9 100644
--- a/packages/dashboard-plugin-example/src/index.tsx
+++ b/packages/dashboard-plugin-example/src/index.tsx
@@ -71,7 +71,9 @@ defineTable<Brand>('brands', {
render: (b) => (
<Link
to={'/$storeId/brands/$brandId' as string}
- params={{ brandId: b.id }}
+ // Registry routes aren't in the generated route tree, so the param
+ // object needs the same escape hatch as `to`.
+ params={{ brandId: b.id } as never}
className="font-medium text-foreground no-underline"
>
{b.name}
diff --git a/packages/dashboard/package.json b/packages/dashboard/package.json
index 10a7fc58f0..d5931638f8 100644
--- a/packages/dashboard/package.json
+++ b/packages/dashboard/package.json
@@ -70,6 +70,7 @@
},
"devDependencies": {
"@playwright/test": "^1.59.1",
+ "@spree/dashboard-plugin-example": "workspace:^",
"@tanstack/router-plugin": "^1.167.35",
"@types/node": "^25.6.0",
"@types/react": "^19.2.14",
diff --git a/packages/dashboard/src/main.tsx b/packages/dashboard/src/main.tsx
index 9ee0c85edd..50fca90455 100644
--- a/packages/dashboard/src/main.tsx
+++ b/packages/dashboard/src/main.tsx
@@ -17,6 +17,16 @@ import { ThemeProvider } from '@spree/dashboard-ui'
import { router } from '@/router'
import '@/styles.css'
+// Dev-only: run the reference plugin (packages/dashboard-plugin-example)
+// against the real shell with VITE_EXAMPLE_PLUGIN=true. Keeps the example
+// honest — its slots, routes, and table extensions render in a live
+// dashboard instead of only existing on paper. Awaited so registration
+// lands before the first render, same contract as any plugin import.
+// Statically eliminated from production builds via the DEV guard.
+if (import.meta.env.DEV && import.meta.env.VITE_EXAMPLE_PLUGIN === 'true') {
+ await import('@spree/dashboard-plugin-example')
+}
+
createRoot(document.getElementById('root')!).render(
<StrictMode>
<QueryClientProvider client={queryClient}>
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 4599e415b8..2b8e83d679 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -277,6 +277,9 @@ importers:
'@playwright/test':
specifier: ^1.59.1
version: 1.59.1
+ '@spree/dashboard-plugin-example':
+ specifier: workspace:^
+ version: link:../dashboard-plugin-example
'@tanstack/router-plugin':
specifier: ^1.167.35