Complete guide to configuring the TypeScript SDK for different environments and use cases
The StorefrontSDK provides extensive configuration options to fit any environment or use case, from simple prototyping to complex production deployments.
Your unique store identifier from the Commerce Engine dashboard.
API key for authentication endpoints. Required for anonymous authentication and initial token acquisition.
Target environment for API requests. Controls which API endpoints are used.
Available Environments:
Environment.Production
β https://prod.api.commercengine.io/api/v1/{storeId}/storefront
Environment.Staging
β https://staging.api.commercengine.io/api/v1/{storeId}/storefront
Custom base URL that overrides the environment setting. Useful for on-premise deployments or custom endpoints.
When baseUrl
is provided, the environment
setting is ignored. Ensure your custom URL follows the correct API path structure.
Initial access token for manual token management or as a starting token for automatic management.
Behavior:
Initial refresh token. Only used when tokenStorage
is provided for automatic token management.
Token storage implementation for automatic token management. See Token Management for detailed information.
Request timeout in milliseconds. When not set, uses the default fetch timeout behavior.
Recommended timeouts:
Default headers applied to all API requests. These can be overridden at the method level.
Supported Headers:
customer_group_id
: Used for customer-specific pricing, promotions, and subscription ratesEnable detailed request/response logging for development and troubleshooting.
Debug Information Includes:
Custom logger function for debug information. If not provided and debug is enabled, uses console.log
.
Logger Interface:
For detailed framework integration patterns including token storage, context setup, and best practices, see our dedicated guides:
SSR/SSG compatible configuration with universal token storage
Client-side configuration with context providers and hooks
Server-side configuration for API routes and background jobs
Complete guide to automatic token management and storage options
Basic configuration examples for different environments:
Always use environment variables for sensitive configuration like API keys and store IDs
Use secure cookie settings in production with appropriate SameSite and Secure flags
Set appropriate timeouts for your environment - longer for development, shorter for production
Enable debugging in development but disable in production for performance and security
Use Environment Variables
Secure Cookie Configuration
Environment-Specific Settings
Never commit API keys or sensitive configuration to version control. Use environment variables and .env
files that are excluded from your repository.
Configuration Summary: The SDKβs flexible configuration system allows you to adapt to any environment while maintaining security and performance. Use automatic token management with appropriate storage for your platform, and always follow security best practices for production deployments.