Why Migrate to the SDK?
Automatic Token Management
No more manual token refresh logic - handled automatically by the SDK
100% Type Safety
Complete TypeScript support with IntelliSense and compile-time error checking
Simplified Error Handling
Consistent error patterns with typed error responses across all endpoints
Built-in Best Practices
Authentication flows and performance optimizations included out of the box
Migration Steps
1
Install the SDK
Replace your manual fetch calls with the SDK:
2
Initialize the Client
Replace your API configuration with SDK initialization:
- Before (Direct API)
- After (SDK)
3
Update API Calls
Replace manual fetch calls with type-safe SDK methods:
- Before (Direct API)
- After (SDK)
4
Update Authentication
Replace manual authentication with SDK auth methods:
- Before (Direct API)
- After (SDK)
Common Migration Patterns
Cart Management
- Before (Direct API)
- After (SDK)
Error Handling
- Before (Direct API)
- After (SDK)
Migration Checklist
1
Replace API Configuration
- Install SDK package
- Replace manual API config with SDK initialization
- Configure token storage (BrowserTokenStorage, CookieTokenStorage, etc.)
2
Update Authentication
- Replace manual token management with SDK auth methods
- Remove custom token refresh logic
- Update login/logout flows to use SDK methods
3
Migrate API Calls
- Replace fetch calls with SDK client methods
- Add TypeScript types to replace
anytypes - Update error handling to use SDK error patterns
4
Test & Optimize
- Test all authentication flows
- Verify token management across browser tabs
- Enable debug mode for development
- Add performance monitoring
Benefits After Migration
Development Experience
Development Experience
- IntelliSense: Complete autocomplete for all API methods and parameters
- Type Safety: Compile-time error checking prevents runtime issues
- Better Debugging: Built-in logging and error tracking
- Reduced Boilerplate: No more manual token management code
Authentication & Security
Authentication & Security
- Automatic Token Refresh: No more expired token errors
- Secure Storage: Built-in secure token storage options
- Cross-tab Sync: Token updates sync across browser tabs
- Session Management: Handles anonymous-to-authenticated transitions
Performance & Reliability
Performance & Reliability
- Request Optimization: Built-in connection pooling and optimization
- Error Recovery: Automatic retry logic for failed requests
- Caching Support: Built-in caching middleware support
- Production Ready: Battle-tested in production environments
Need Help?
If you encounter issues during migration:- Enable Debug Mode: Set
debug: truein SDK configuration - Check Documentation: Review API Reference for endpoint details
- Follow Patterns: Reference Storefront Guides for business logic
- Type Safety: Use TypeScript for better development experience
The SDK is designed to be a drop-in replacement for direct API calls while providing significant improvements in developer experience, type safety, and reliability.