/storefront-next:sfnext-routingfrom storefront-next
Adds and manages file-based routes in a Storefront Next project using React Router 7 framework mode. Covers flat-file routes, layout routes, splat routes, action/resource routes, route-paths.ts, site-aware Link/navigate wrappers, SEO head tags, multi-site URL prefixes, extension routes, and SLAS callback routes.
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.
Storefront Next uses React Router 7 framework mode with file-based routes. Every route module lives in src/routes/; the file name is the URL. Your project also ships docs/README-MULTI-SITE.md (URL prefix, locale and site detection) and docs/README-SEO.md (titles, meta tags, canonical URLs); read those for depth.
src/routes.ts imports flatRoutes from @salesforce/storefront-next-runtime/routing (not @react-router/fs-routes). It is a drop-in wrapper that:
src/routes/ (test files are ignored),src/extensions/<name>/routes/ (see storefront-next:sfnext-extensions),app.url.prefix pattern (default /:siteId/:localeId) through src/app-wrapper.tsx, and applies app.url.seoRoutes aliases to the product and category splats.The two SLAS callback routes (resource.slas-reset-password-callback.ts, resource.slas-passwordless-login-callback.ts) are deliberately excluded from discovery in src/routes.ts and registered by hand at the bare paths /reset-password-callback and /passwordless-login-callback, outside the prefix, so a single callback URL works for all sites. If you add another server-to-server callback that cannot carry a site prefix, follow the same pattern in src/routes.ts.
| Pattern | Files | Notes |
|---|---|---|
_app layout | _app.tsx | header/footer shell; loads navigation; shouldRevalidate returns false |
| Home, search, cart, wishlist | _app._index.tsx, _app.search.tsx, _app.cart.tsx, _app.wishlist.tsx, _app.about-us.tsx | |
| Product detail | _app.p.$.tsx | splat; URL shape is build-time configurable (url.seoRoutes) |
| Category / listing | _app.c.$.tsx | splat; URL shape is build-time configurable (url.seoRoutes) |
| Account | _app.account.tsx (layout + auth guard), _app.account.overview, .orders, .orders.$orderNo, .addresses, .payment-methods, .wishlist, .passkeys, .store-preferences | |
| Orders | _app.order-confirmation.$orderNo.tsx, _app.order-lookup.* (results.$orderNo, verify.$orderNo) | param is $orderNo |
_checkout layout | _checkout.tsx, _checkout.checkout.tsx | checkout chrome |
_empty layout | _empty.tsx, _empty.login, .signup, .forgot-password, .reset-password, .logout, .maintenance, .oauth2.jwks, .preview.component, _empty.$.tsx (catch-all) | no header/footer; there is no _auth layout |
| Mutations | action.*.ts(x) (cart, wishlist, checkout, OTP, passkey, consent, site context...) | no UI; see storefront-next:sfnext-data-fetching |
| Data endpoints | resource.*.ts(x) (recommendations, basket-products, category-products, analytics-proxy, resource.api.client.$resource.ts...) | no UI |
Naming rules (flat routes): . becomes /, $name is a param, $ alone is a splat, a leading _ segment is a pathless layout, _index is the index route. Pick the layout by prefix: _app. for standard pages, _checkout. for checkout, _empty. for header-less pages.
// src/routes/_app.shipping-policy.tsx -> /shipping-policy
import type { Route } from './+types/_app.shipping-policy';
import { SeoMeta } from '@/components/seo-meta';
import { Link } from '@/components/link';
import { routes } from '@/route-paths';
export async function loader({ request }: Route.LoaderArgs) {
return { pageUrl: new URL(request.url).href };
}
export default function ShippingPolicy({ loaderData }: Route.ComponentProps) {
return (
<>
<SeoMeta title="Shipping policy" description="How we ship." openGraph={{ url: loaderData.pageUrl }} />
<h1>Shipping policy</h1>
<Link to={routes.cart}>Back to cart</Link>
</>
);
}
Checklist for a new page:
src/routes/ with the right layout prefix../+types/<file-name> (Route.LoaderArgs, Route.ComponentProps, Route.ActionArgs). These are generated by pnpm typecheck (runs react-router typegen) and pnpm dev; run one if the import is unresolved.routes (page) or resourceRoutes (action/resource) in src/route-paths.ts. That file is the single source of truth for navigable paths. Keep it in sync when you rename or delete route files.<SeoMeta> (and <JsonLd> from @/components/json-ld for structured data) inside the component. React 19 hoists these tags to <head> and they work with streaming. Use meta exports only when a route already does.storefront-next:sfnext-i18n) and a test next to the route (storefront-next:sfnext-testing).import { Link, NavLink } from '@/components/link';
import { useNavigate } from '@/hooks/use-navigate';
import { href } from 'react-router';
import { routes, routeHref, resourceRoutes } from '@/route-paths';
<Link to={routes.cart}>Cart</Link>
<Link to={routeHref(routes.accountOrderDetail, { orderNo })}>Order</Link>
Link, NavLink and useNavigate from @/components/link and @/hooks/use-navigate apply the site/locale prefix (buildUrl). The React Router originals compile but silently produce unprefixed URLs that break multi-site routing. AGENTS.md makes this a hard rule.
For product and category URLs use the helpers in @/route-paths (createProductUrl, createCategoryUrl, createCategoryNavigationUrl) with the SEO URL context so links follow url.seoRoutes. In server code (redirects), use buildUrlFromContext(routes.login, context) from @/lib/url.server:
import { redirect } from 'react-router';
import { routes } from '@/route-paths';
import { buildUrlFromContext } from '@/lib/url.server';
throw redirect(buildUrlFromContext(routes.login, context));
Form and fetcher action targets come from resourceRoutes (for example resourceRoutes.cartItemAdd), which are excluded from the site prefix via app.url.excludeRoutes in config.server.ts (['/resource/**', '/action/**'] by default). A new action.* or resource.* route needs no prefix handling; a new page route gets it automatically.
app.url in config.server.ts (prefix, excludeRoutes and seoRoutes are protected config paths: set them in the file and rebuild, they cannot be overridden with PUBLIC__ env vars; see storefront-next:sfnext-configuration) controls prefix, excludeRoutes, search-param mode, detection and seoRoutes (configurable product and category URL grammars). Changing the prefix or seoRoutes affects every link; follow docs/README-MULTI-SITE.md in your project rather than editing ad hoc.
There is no _auth layout. Guard in the loader: read the session with getAuth(context) from @/middlewares/auth.server and throw redirect(...) to routes.login (see _app.account.tsx and _app.wishlist.tsx). Auth details: storefront-next:sfnext-authentication.
loader and action exports are allowed; no clientLoader/clientAction.new Response('...', { status: 404 }) for missing content so the right HTTP status reaches crawlers.resource.recommendations.ts for the pattern).Read AGENTS.md in your project for the doc index. For other framework questions use b2c docs search "storefront next routing" (or the docs_search MCP tool).
storefront-next:sfnext-data-fetching - loaders, actions, fetchersstorefront-next:sfnext-revalidation - shouldRevalidate policy per routestorefront-next:sfnext-seo - canonical URLs, structured data, sitemapsstorefront-next:sfnext-page-designer - @PageType and regions on routesstorefront-next:sfnext-extensions - routes contributed by extensionsstorefront-next:sfnext-authentication - sessions and login flowsstorefront-next:sfnext-overview - architecture mapWhat SKILL.md sets; muted values are Claude Code's defaults
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