/storefront-next:sfnext-page-designerfrom storefront-next
Builds and manages merchant-editable Page Designer content in Storefront Next projects using decorators, region rendering, and component loaders. Use when adding/editing components, exposing regions on routes, or debugging palette/rendering issues.
Ships in storefront-next. 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.
Read when SKILL.md points to them.
In Storefront Next your React components are the Page Designer components. You annotate them with decorators, the build generates Business Manager metadata (JSON) from those decorators, and at runtime a route loader fetches the page structure from the Shopper Experience API and <Region> renders it.
The in-project guide is docs/README-PAGE-DESIGNER.md and the rules in AGENTS.md apply; this skill is the task-oriented path through them. Where the guide and the source disagree, trust the source.
| Piece | Location in your project |
|---|---|
Decorators (Component, AttributeDefinition, RegionDefinition, PageType) | @/lib/decorators (src/lib/decorators/) |
| Page fetch with per-component loader promises | fetchPageWithComponentData in @/lib/page-designer/page-loader.server |
| Single-component fetch (preview, embedded) | fetchComponentWithComponentData in @/lib/page-designer/component-loader.server |
| Region renderer | Region from @/components/region |
| Generated registry (do not hand-edit) | src/lib/page-designer/static-registry.ts |
Runtime hooks (usePageDesignerMode) | @salesforce/storefront-next-runtime/design/react/core |
| Design/preview mode detection in loaders | isDesignModeActive / isPreviewModeActive from @salesforce/storefront-next-runtime/design/mode |
| Generated Business Manager metadata | cartridges/app_storefrontnext_base/cartridge/experience/{components,pages,aspects} |
The runtime package's /design entry exports only the registry. Decorators come from your project, not from @salesforce/storefront-next-runtime.
fallback, optional loader) under src/components/<name>/index.tsx.pnpm dev (or pnpm build). The Vite plugin scans src/components for @Component and rewrites the registry between the STATIC_REGISTRY_START/END markers.pnpm cartridge:generate writes the metadata JSON (pnpm build runs it for you).pnpm cartridge:validate checks the generated JSON against the schemas. Generation also fails on an invalid attribute config (for example a bad searching combination).pnpm cartridge:deploy uploads the cartridge to the B2C instance (pnpm cartridge:deploy -- --delete removes old cartridge files first). The optional MCP tool cartridge_deploy does the same. See b2c-cli:b2c-code for credentials and code-version handling.// src/components/promo-banner/index.tsx
import { AttributeDefinition, Component, RegionDefinition } from '@/lib/decorators';
import { DynamicImage } from '@/components/dynamic-image';
import { type Image } from '@/types';
import { cn } from '@/lib/utils';
@Component('promoBanner', {
name: 'Promo Banner',
description: 'Headline and optional image. Headline text and alignment are editable.',
group: 'Content',
})
@RegionDefinition([])
export class PromoBannerMetadata {
@AttributeDefinition({ id: 'headline', name: 'Headline', type: 'string', required: true, defaultValue: 'Spring sale' })
headline?: string;
@AttributeDefinition({ id: 'image', name: 'Image', type: 'image' })
image?: Image;
@AttributeDefinition({ id: 'align', name: 'Alignment', type: 'enum', values: ['left', 'center'], defaultValue: 'left' })
align?: 'left' | 'center';
}
interface PromoBannerProps {
headline?: string;
image?: Image;
align?: 'left' | 'center';
className?: string;
}
// Page Designer also injects component, data, designMetadata and regionId.
// Never spread them onto a DOM element; destructure them out first if you forward ...rest.
export default function PromoBanner({ headline = 'Spring sale', image, align = 'left', className }: PromoBannerProps) {
return (
<section className={cn('relative', align === 'center' && 'text-center', className)}>
{image?.url && <DynamicImage src={image.url} alt="" />}
<h2>{headline}</h2>
</section>
);
}
// REQUIRED. Rendered in a Suspense boundary; receives the same attribute props. Keep it light.
export function fallback() {
return <div className="h-48 animate-pulse bg-muted" />;
}
Rules that matter:
id must agree.exported; the generator only sees exported classes.typeId must be a string literal. It is stored as <group>.<typeId> (default group storefrontnext_base), for example Content.promoBanner. Use the group option (Content, Layout, ...) so related components sit together in the palette.image attribute delivers an object ({ url, focalPoint?, metaData? }), typed Image from @/types, not a string. Check src/components/hero/index.tsx for the pattern.name and description are what merchants read in Business Manager; omitted ones fall back to the raw id.Export a callable named loader when the component needs data (products, categories, your own API). It receives { componentData, context, request }; componentData is the whole SCAPI component object, so merchant-set attributes live at componentData.data.
// src/components/promo-products/loaders.ts
import type { LoaderFunctionArgs } from 'react-router';
import type { ShopperExperience } from '@/scapi';
import { fetchProductsByIds } from '@/lib/api/products.server';
export const loader = async (args: { componentData: unknown; context: LoaderFunctionArgs['context'] }) => {
const comp = args.componentData as ShopperExperience.schemas['Component'];
const { productIds } = (comp.data ?? {}) as { productIds?: string };
if (!productIds) return null;
return fetchProductsByIds(args.context, productIds.split(','));
};
// src/components/promo-products/index.tsx
export { loader } from './loaders';
export function fallback() { /* skeleton with reserved height */ }
export default function PromoProducts({ data }: { data?: Product[] | null }) { /* ... */ }
loader must be a function. An object such as { server: fn } is silently ignored and data stays undefined; unwrap it (export const loader = loaders.server), as product-tile/index.tsx does.*.server modules; the component file must not. An optional clientLoader export is client-only.null when nothing is configured, fetch in parallel with Promise.all, and let errors propagate so only that component is hidden.{ loader: 'loader' } and { fallback: 'fallback' } capability flags for you on regeneration.More on the registry shape, group-qualified ids, preload manifest and entry wiring: Registry and Loading.
Routes bind a URL to a Page Designer page template and render its regions. Routes with @PageType today: home (_app._index.tsx), PLP (_app.c.$.tsx), PDP (_app.p.$.tsx), search (_app.search.tsx), about-us (_app.about-us.tsx), and the component preview route. Cart, checkout, account and auth do not use Page Designer.
import { Region } from '@/components/region';
import { PageType } from '@/lib/decorators/page-type';
import { RegionDefinition } from '@/lib/decorators/region-definition';
import { fetchPageWithComponentData } from '@/lib/page-designer/page-loader.server';
@PageType({
name: 'Landing Page',
description: 'Campaign landing page with a banner and a main content area',
supportedAspectTypes: [],
})
@RegionDefinition([
{ id: 'banner', name: 'Banner Region', maxComponents: 1 },
{ id: 'main', name: 'Main Region' },
])
export class LandingPageMetadata {}
export function loader(args: Route.LoaderArgs) {
return { page: fetchPageWithComponentData(args, { pageId: 'landing' }) };
}
export default function Landing({ loaderData }: Route.ComponentProps) {
return (
<>
<Region page={loaderData.page} regionId="banner" />
<Region page={loaderData.page} regionId="main" />
</>
);
}
{ pageId } for a fixed page, or by aspect: { aspectType: 'pdp', productId, categoryId? } and { aspectType: 'plp', categoryId }. The aspectType passed to the fetch must agree with @PageType.supportedAspectTypes (['pdp'], ['plp'], or [] for fixed-page routes such as home); a mismatch shows the wrong template in Business Manager with no error.fetchPageWithComponentData attaches the per-component loader promises to the page (page.componentData). <Region> reads them itself; it takes no componentData prop, and the loader returns just { page }. It resolves to null when the page is missing (404) or SCAPI errors, so empty regions are the normal unconfigured state.<Region page={...}> accepts a promise and renders in Suspense. Add fallbackElement only for a visible skeleton.critical to a page-level region only for above-the-fold or LCP content, and only with an awaited page (page: await fetchPageWithComponentData(...)), as _app._index.tsx does. Never on below-the-fold or catch-all regions. Details in Registry and Loading.<Region component={component} regionId="content" />. No Suspense wrapper, no fallbackElement, no promises. See src/components/grid/index.tsx.errorElement to render hard-coded content for an unconfigured page: it defeats merchant control and forces loaders to fetch data only for the fallback. The home route still contains such an errorElement; do not copy it. Use fallbackElement for loading and render nothing for empty.@AttributeDefinition.Business Manager loads your storefront in an iframe. In loaders use isDesignModeActive(request) / isPreviewModeActive(request) (the page loader already does and switches to the pageId/pdToken passed by Business Manager). In components use usePageDesignerMode() from @salesforce/storefront-next-runtime/design/react/core. PageDesignerInit (src/page-designer-init.tsx, rendered by root.tsx) blocks link navigation while editing and loads design-mode styles; do not remove it.
typeId literal; group set; every attribute has name, description, correct typefallback exported and lightweight; loader (if any) is a function<Region regionId> matches a @RegionDefinition id, and vice versapnpm cartridge:generate && pnpm cartridge:validate pass; the component is in static-registry.tsroute and aspectTypeIds, page setup, palettestorefront-next:sfnext-components - component conventions, shadcn primitives, Storybookstorefront-next:sfnext-data-fetching - loaders, createApiClients, streaming with Suspense/Awaitstorefront-next:sfnext-scapi - calling SCAPI from loaders and actionsstorefront-next:sfnext-performance - LCP, preload, critical datastorefront-next:sfnext-theming - tokens and brand styling for new componentsstorefront-next:sfnext-testing - component and story testsstorefront-next:sfnext-deployment - shipping the storefront bundlefigma-to-sfnext-pagedesigner:figma-to-sfnext-pagedesigner - Figma frame to Page Designer blocksb2c:b2c-page-designer - classic (ISML/SFRA) Page Designerb2c-cli:b2c-code - deploying cartridges and code versionsevals/trigger-evals.json (opens in a new tab)references/BUSINESS-MANAGER.md (opens in a new tab)references/COMPONENT-REGISTRY.md (opens in a new tab)references/DECORATOR-PATTERNS.md (opens in a new tab)references/REVIEW-CHECKLIST.md (opens in a new tab)references/TROUBLESHOOTING.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
25 skills in this plugin
/sfnext-accessibilityBuild and fix accessible UI in a Storefront Next storefront (WCAG 2.1 AA): jsx-a11y lint findings, missing accessible names and labels, form error association, dialog focus management, aria-live status messages, keyboard behavior, color contrast, and verifying fixes with Storybook a11y/play() tests and the e2e axe scan with its baseline. Use for "accessibility", "a11y", "WCAG", "screen reader", "aria-label", "focus trap", "axe violation", pnpm lint:a11y, pnpm a11y, a11y-baseline.json, skip-a11y, STORYBOOK_A11Y_TEST_MODE, or an accessibility audit finding to fix. Do not use for general lint/typecheck gates (use `storefront-next:sfnext-quality-gates`), writing non-accessibility tests (use `storefront-next:sfnext-testing`), or color/token design (use `storefront-next:sfnext-theming`)./sfnext-analytics-consentStorefront Next analytics: engagement adapters (Einstein, Active Data, Data 360), adding a custom adapter, tracking consent gating, PageViewTracker, useAnalytics events, and first-touch attribution (dw_attribution). Use when configuring engagement.adapters in config.server.ts, writing an adapter with hasConsent, registering it in initializeEngagementAdapters, wiring the consent banner (trackingConsent, consentCategories, dw_dnt), firing trackViewProduct/trackCartItemAdd events, debugging why no analytics events are sent, or passing campaign attribution to orders. Do not use for general config loading or env vars (use `storefront-next:sfnext-configuration`), CSP/script allowlisting of third-party tags (use `storefront-next:sfnext-security`), or SEO meta/JSON-LD (use `storefront-next:sfnext-seo`).npx claudepluginhub salesforcecommercecloud/b2c-developer-tooling --plugin storefront-nextOther plugins' skills for the same job