Skip to main content
The SDK works excellently in Node.js applications for backend services, APIs, and server-side e-commerce operations.

NPM Package

@commercengine/storefront

Node.js integration for Commerce Engine Storefront SDK.

Installation

Install the SDK in your Node.js project:

Basic Setup

Configure the SDK for server-side usage:

Environment Variables

Set up your environment configuration:

Token Management Strategies

Memory Storage (Default)

For simple server applications or stateless operations:

Database Integration

For persistent token storage across server restarts:

Redis Integration

For distributed systems with shared token storage:

Express.js Integration

Basic Express Setup

Middleware for User Context

Background Jobs

Order Processing

Webhook Handlers

Microservices Architecture

Service-to-Service Communication

Health Checks

Error Handling

Global Error Handler

Graceful Shutdown

Performance Considerations

Request Timeouts

Connection Monitoring

Best Practices

Environment Configuration

Use environment variables for all configuration and never hardcode sensitive values

Error Handling

Implement comprehensive error handling for all SDK operations with appropriate logging

Token Storage

Choose appropriate token storage based on your architecture (memory, database, Redis)

Health Monitoring

Implement health checks and monitoring to ensure SDK connectivity and performance

Cross-References

The SDK is optimized for server-side usage with proper timeout handling and token management. Choose your token storage strategy based on your application architecture and scaling requirements.