From storefront-next
Manages Storefront Next application configuration via config.server.ts, environment variables, and multi-site setup. Use when editing config or adding PUBLIC__ env vars.
How this skill is triggered — by the user, by Claude, or both
Slash command
/storefront-next:sfnext-configurationThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
This skill covers the Storefront Next configuration system — centralized in `config.server.ts` with environment variable overrides.
This skill covers the Storefront Next configuration system — centralized in config.server.ts with environment variable overrides.
All configuration is centralized in config.server.ts with typed defaults. Environment variables (via .env files or MRT settings) override these defaults. The system provides type-safe access with automatic parsing and validation.
src/types/config.tsexport type Config = {
app: {
myFeature: {
enabled: boolean;
maxItems: number;
};
};
};
config.server.tsexport default defineConfig({
app: {
myFeature: {
enabled: false,
maxItems: 10,
},
},
});
PUBLIC__app__myFeature__enabled=true
PUBLIC__app__myFeature__maxItems=20
import { useConfig } from '@salesforce/storefront-next-runtime/config';
export function MyComponent() {
const config = useConfig();
if (config.myFeature.enabled) {
const maxItems = config.myFeature.maxItems;
// Feature code
}
}
import { getConfig } from '@salesforce/storefront-next-runtime/config';
export function loader({context}: LoaderFunctionArgs) {
const config = getConfig(context); // context is required on server
if (config.myFeature.enabled) {
// Loader code
}
}
import { getConfig } from '@salesforce/storefront-next-runtime/config';
export function getFeatureFlag() {
const config = getConfig(); // No context needed in browser (uses window.__APP_CONFIG__)
return config.myFeature.enabled;
}
Note: getConfig() and useConfig() return AppConfig — the app section of the full config. Access properties directly (e.g., config.myFeature.enabled) without the app prefix.
# Pattern: PUBLIC__app__{path}__{to}__{property}=value
PUBLIC__app__commerce__api__clientId=abc123
# Maps to config.app.commerce.api.clientId
# Accessed as config.commerce.api.clientId
| Rule | Detail |
|---|---|
PUBLIC__ prefix | Exposed to browser (client-safe) |
| No prefix | Server-only (secrets) |
__ separator | Navigate nested paths |
| Auto-parsing | Numbers, booleans, JSON parsed automatically |
| Validation | Paths must exist in config.server.ts |
| Depth limit | Maximum 10 levels |
| MRT limits | Names max 512 chars; total PUBLIC__ max 32KB |
PUBLIC__app__commerce__sites='[
{
"id": "RefArchGlobal",
"defaultLocale": "en-US",
"defaultCurrency": "USD",
"supportedLocales": [
{"id": "en-US", "preferredCurrency": "USD"},
{"id": "de-DE", "preferredCurrency": "EUR"}
],
"supportedCurrencies": ["USD", "EUR"]
}
]'
const config = getConfig(context);
const currentSite = config.commerce.sites[0];
const locale = currentSite.defaultLocale; // "en-US"
const currency = currentSite.defaultCurrency; // "USD"
# Client-safe (PUBLIC__ prefix)
PUBLIC__app__commerce__api__clientId=abc123
# Server-only (no prefix — never sent to client)
COMMERCE_API_SLAS_SECRET=your-secret
Read server-only secrets directly from process.env — never add them to the config system.
| Pitfall | Problem | Solution |
|---|---|---|
Missing context | getConfig() returns undefined in loaders | Use getConfig(context) on server |
| Typo in env var | Variable silently ignored | Validation catches paths not in config.server.ts |
| Exposing secrets | Sensitive data in browser | Use no-prefix variables; access via process.env |
storefront-next:sfnext-project-setup - Initial environment setup and .env configurationstorefront-next:sfnext-data-fetching - Using config in loader functionsstorefront-next:sfnext-deployment - MRT environment variable configurationnpx claudepluginhub salesforcecommercecloud/b2c-developer-tooling --plugin storefront-nextCreates and configures Storefront Next projects for Salesforce Commerce Cloud. Covers CLI creation, project structure, environment variables, and the sfnext development workflow.
Build Next.js/React apps for Saleor storefronts/Apps with App Router conventions, server/client components, GraphQL integration, MacawUI, and Tailwind CSS.
Provides patterns for Next.js 15 storefronts with Medusa v2: App Router structure, server/client components, JS SDK integration, data fetching, caching, server actions.