/storefront-next:sfnext-configurationfrom storefront-next
Guides configuring Storefront Next apps via config.server.ts: defineConfig, typed AppConfig, PUBLIC__ env overrides, getConfig/useConfig, multi-site setup, and checklist items for pre-launch.
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.
All app settings live in one typed file, config.server.ts. Environment variables override its values per environment; defineConfig() deep-merges them at startup. Full references ship in the project: docs/README-CONFIG.md (required/optional variable tables) and docs/README-CONFIG-OPTIONS.md (every option).
config.server.ts default-exports defineConfig<Config>({ metadata, runtime, app }, { protectedPaths }), imported from @salesforce/storefront-next-runtime/config.
| Section | Visible to | Contents |
|---|---|---|
app | Server and browser (window.__APP_CONFIG__) | Commerce API, sites, features, URL/SEO routes, images, security, engagement |
runtime | Server only | MRT settings such as ssrParameters (ssrFunctionNodeVersion, envBasePath), ssrOnly, ssrShared |
metadata | Server only | Project name/slug |
Because app reaches the browser, never put secrets in it.
AppConfig in src/types/config.ts (Config = BaseConfig<AppConfig>; the AppConfigShape / ClientFacingAppConfigShape augmentations in that file give getConfig and useConfig their types).app in config.server.ts. Define the key even if the default is empty ('', []); env overrides are only accepted for paths that exist here.PUBLIC__app__myFeature__enabled=true.pnpm typecheck.// src/types/config.ts (inside AppConfig)
myFeature: { enabled: boolean; maxItems: number };
// config.server.ts (inside app)
myFeature: { enabled: false, maxItems: 10 },
import { getConfig, useConfig } from '@salesforce/storefront-next-runtime/config';
// Loaders, actions, middleware (server): context is REQUIRED
export function loader({ context }: LoaderFunctionArgs) {
const config = getConfig(context); // full AppConfig incl. serverExtension
return { max: config.myFeature.maxItems };
}
// Components
const config = useConfig(); // client-facing shape (no serverExtension)
getConfig() with no argument is for browser-only modules (reads window.__APP_CONFIG__); it returns the client-facing shape. Calling it on the server without a context throws "Configuration not available".clientLoader (forbidden by the project rules), so server code always passes context.context.get(appConfigContext) (exported from the same module).mockConfig, mockBuildConfig, ConfigWrapper, createConfigWrapper from @/test-utils/config.PUBLIC__app__<path>__<to>__<key>=value -> config.app.<path>.<to>.<key>
| Rule | Detail |
|---|---|
PUBLIC__ prefix | Merged into config and exposed to the browser. Client IDs, flags, site lists only |
| No prefix | Server-only; not part of config. Read with process.env in server code |
| Path must exist | An unknown path is skipped with [Config Warning] Ignoring environment variable ... in the server log, so a typo is silent to the user |
| Parsing | Numbers, true/false (as strings), JSON arrays/objects; empty value becomes '' |
| Precedence | Deeper (more specific) paths win over a JSON blob at a parent path |
| Case | Path matching is case-insensitive |
| Depth | Max 10 segments; use a JSON value for deeper structures |
| Restart | .env is read at startup; restart pnpm dev |
Only three are required to boot (.env locally; MRT environment variables when deployed):
PUBLIC__app__commerce__api__clientId=...
PUBLIC__app__commerce__api__organizationId=...
PUBLIC__app__commerce__api__shortCode=...
Do not set PUBLIC__app__commerce__api__siteId; that path does not exist and is ignored with a warning. To point at your own site, set PUBLIC__app__defaultSiteId and PUBLIC__app__commerce__sites (see MULTI-SITE-URLS.md). Everything else is optional; see ENV-VARIABLES.md.
pnpm config:inspect # shows each value and whether it comes from config.server.ts, .env, or MRT
pnpm sfnext config inspect --project my-project --environment staging # include MRT env values
pnpm config:push-env # push .env variables to an MRT environment (b2c mrt env var push)
The config:inspect script echoes a tip after the command, so call sfnext config inspect directly when passing flags.
Checklist: PUBLIC__ with a double underscore, path exists in config.server.ts, booleans are the string true, dev server restarted, variable set on the right MRT environment, and the path is not protected.
defineConfig(..., { protectedPaths }) locks paths against env override. Setting a protected path, or a parent of one (e.g. PUBLIC__app__url), throws at startup. The template protects:
app__url__prefix, app__url__excludeRoutes, app__url__seoRoutes (compiled into routes at build time; change config.server.ts and rebuild/redeploy)app__engagement__adapters__einstein, ...__data360, ...__activeData__enabled, ...__activeData__eventTogglesThe rest of app.engagement is overridable. Check the protectedConfigPaths export in your config.server.ts for the current list.
Server-only values are plain env vars read via process.env in server routes/middleware, never through config:
COMMERCE_API_SLAS_SECRET: only for a private SLAS client (commerce.api.privateKeyEnabled). A public client needs no secret.GUEST_ORDER_LOOKUP_COOKIE_SECRET: required when guest order lookup is enabled.MARKETING_CLOUD_*: only for email-mode passwordless/reset with your own Marketing Cloud tenant.Extension config.ts / server-config.ts must not read process.env (an AST check fails discovery).
Extensions add config without touching core files:
src/extensions/<name>/config.ts (default-export an object) is merged into app.extension.<camelCaseFolder>; override with PUBLIC__app__extension__<key>__<setting>.src/extensions/<name>/server-config.ts is merged into app.serverExtension.<camelCaseFolder>, available only through getConfig(context); no env override, and the build fails if a client chunk imports it.pnpm config:aggregate-extensions regenerates the merged files (run automatically by dev, build, typecheck).Short version: the current site comes from the request (site-context middleware), not from commerce.sites[0]. Use useSite() from @salesforce/storefront-next-runtime/site-context in components and context.get(siteContext) (same module) on the server. URL shape, seoRoutes, aliases, MRT Data Store sites, cookie domain, multiple domains, and base path are in MULTI-SITE-URLS.md.
Before going live, review these defaults in config.server.ts:
app.engagement.adapters (Einstein, Active Data, Data 360): defaults carry demo IDs/hosts. Enable only with your own values, or disable them; also confirm consent categories.images.host defaults to the DIS staging host (edge.disstg...); use the production DIS host, and add realmHostMappings for custom domains..env / MRT variables point at your own client ID, organization ID, short code, and site(s), not the demo backend.commerce.sites, defaultSiteId, and siteAliasMap match your Business Manager sites; url.seoRoutes has an entry for every active site if enabled.cookies.domain) matches Business Manager Hybrid Auth level if used.app.security.headers) and Turnstile keys are reviewed (storefront-next:sfnext-security).storefront-next:sfnext-project-setup - Create the project, .env basics, scriptsstorefront-next:sfnext-deployment - Push bundles and sync MRT env varsstorefront-next:sfnext-routing - Site-aware links and SEO route behaviorstorefront-next:sfnext-i18n - Locales, translations, locale switchingstorefront-next:sfnext-extensions - Extension authoringstorefront-next:sfnext-hybrid-storefronts - Hybrid proxy and shared cookies with SFRAstorefront-next:sfnext-security - Security headers, CSP, Turnstileb2c-cli:b2c-mrt - MRT environment variable managementProject docs/README-CONFIG.md, docs/README-CONFIG-OPTIONS.md, docs/README-MULTI-SITE.md; b2c docs search "<topic>" --category sfnext.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub salesforcecommercecloud/b2c-developer-tooling --plugin storefront-next25 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`).Other plugins' skills for the same job