sfnext-routing
БесплатноБез исполняемых скриптовНе проверенAdd and change pages in a Storefront Next project: flat-file routes in src/routes, layout routes (_app, _checkout, _empty), splat routes for product and…
от SalesforceCommerceCloud★ 58 звёзд на GitHubОб этом скилле
Storefront Next Routing
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.
How routes are discovered
src/routes.ts imports flatRoutes from @salesforce/storefront-next-runtime/routing (not @react-router/fs-routes). It is a drop-in wrapper that:
- scans
src/routes/(test files are ignored), - merges routes from
src/extensions/<name>/routes/(seestorefront-next:sfnext-extensions), - wraps every route in the
app.url.prefixpattern (default/:siteId/:localeId) throughsrc/app-wrapper.tsx, and appliesapp.url.seoRoutesaliases 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.
Route tree (what exists)
| 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.
Add a page
// 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:
- Create the file under
src/routes/with the right layout prefix. - Import types from
./+types/<file-name>(Route.LoaderArgs,Route.ComponentProps,Route.ActionArgs). These are generated bypnpm typecheck(runsreact-router typegen) andpnpm dev; run one if the import is unresolved. - Add an entry to
routes(page) orresourceRoutes(action/resource) insrc/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. - Render
<SeoMeta>(and<JsonLd>from@/components/json-ldfor structured data) inside the component. React 19 hoists these tags to<head>and they work with streaming. Usemetaexports only when a route already does. - Add locale strings for user-facing text (
storefront-next:sfnext-i18n) and a test next to the route (storefront-next:sfnext-testing).
Links and navigation: always use the project wrappers
import { Link, NavLink } from '@/components/link';
import { useNavigate } from '@/hooks/use-navigate';
import { href } from 'react-router';
import { routes, routeHref, resourceRoutes } from '@
Установить sfnext-routing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл sfnext-routing?
Add and change pages in a Storefront Next project: flat-file routes in src/routes, layout routes (_app, _checkout, _empty), splat routes for product and category pages, action.* and resource.* routes, src/route-paths.ts (routes, resourceRoutes, routeHref), site-aware Link and useNavigate wrappers, SeoMeta and JsonLd head tags, multi-site /:siteId/:localeId URL prefixes, url.seoRoutes and excludeRoutes, extension routes, and the SLAS callback routes. Use for "add a page", "new route", "why is my link missing the site prefix", "route file naming", "redirect to login", or a 404 on a new URL. Do not use for loader/action/fetcher data code (use `storefront-next:sfnext-data-fetching`), shouldRevalidate (use `storefront-next:sfnext-revalidation`), SEO strategy such as sitemaps and canonical rules (use `storefront-next:sfnext-seo`), or Page Designer regions (use `storefront-next:sfnext-page-designer`).
Как установить скилл sfnext-routing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл sfnext-routing запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic