sfnext-configuration
БесплатноБез исполняемых скриптовНе проверенConfigure a Storefront Next app: config.server.ts (defineConfig, metadata/runtime/app), AppConfig types in src/types/config.ts, PUBLIC__ environment variable…
от SalesforceCommerceCloud★ 58 звёзд на GitHubОб этом скилле
Storefront Next Configuration
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).
Model
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.
Add a config value
- Add the field to
AppConfiginsrc/types/config.ts(Config = BaseConfig<AppConfig>; theAppConfigShape/ClientFacingAppConfigShapeaugmentations in that file givegetConfiganduseConfigtheir types). - Set a default under
appinconfig.server.ts. Define the key even if the default is empty ('',[]); env overrides are only accepted for paths that exist here. - Override per environment:
PUBLIC__app__myFeature__enabled=true. - Run
pnpm typecheck.
// src/types/config.ts (inside AppConfig)
myFeature: { enabled: boolean; maxItems: number };
// config.server.ts (inside app)
myFeature: { enabled: false, maxItems: 10 },
Read config
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 (readswindow.__APP_CONFIG__); it returns the client-facing shape. Calling it on the server without a context throws "Configuration not available".- Routes have no
clientLoader(forbidden by the project rules), so server code always passescontext. - Middleware can read
context.get(appConfigContext)(exported from the same module). - In tests use
mockConfig,mockBuildConfig,ConfigWrapper,createConfigWrapperfrom@/test-utils/config.
Environment variable rules
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 |
Required variables
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.
Debug "my env var is not applied"
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.
Protected paths
defineConfig(..., { protectedPaths }) locks paths against env override. Setting a protected path, or a parent of one (e.g. PUBLIC__app__url), throws at startup
Установить sfnext-configuration в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл sfnext-configuration?
Configure a Storefront Next app: config.server.ts (defineConfig, metadata/runtime/app), AppConfig types in src/types/config.ts, PUBLIC__ environment variable overrides, getConfig(context) / useConfig(), extension config (app.extension, app.serverExtension), protected paths, server-only secrets, and multi-site settings (commerce.sites, url.prefix, seoRoutes, siteAliasMap, cookie domain). Use when editing config.server.ts, adding a config value, an env var is ignored or "not applied", `pnpm config:inspect` / `config:push-env`, "Ignoring environment variable" warnings, protected config path errors, setting up a second site or locale URLs, or going through the pre-launch config checklist. Do not use for creating a project or the npm script list (use `storefront-next:sfnext-project-setup`), pushing bundles or MRT env management (use `storefront-next:sfnext-deployment` / `b2c-cli:b2c-mrt`), or hybrid proxy and cookie-sharing with SFRA (use `storefront-next:sfnext-hybrid-storefronts`).
Как установить скилл sfnext-configuration?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл sfnext-configuration запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic