Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

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от 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:

  1. scans src/routes/ (test files are ignored),
  2. merges routes from src/extensions/<name>/routes/ (see storefront-next:sfnext-extensions),
  3. wraps every route in the 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.

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:

  1. Create the file under src/routes/ with the right layout prefix.
  2. Import types from ./+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.
  3. Add an entry to 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.
  4. Render <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.
  5. 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 '@
Полный SKILL.md на GitHub

Установить sfnext-routing в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

evals/trigger-evals.jsonreferences/ROUTE-CONVENTIONS.mdreferences/URLS-AND-SEO-ROUTES.md

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), без исполняемых скриптов.

Похожие скиллы

Сравнить sfnext-routing с