Client API
The client API provides the core functionality for creating and configuring your Glood SDK instance.createGlood()
Creates a new Glood client instance with the specified configuration.Signature
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
config | GloodConfig | Yes | Configuration object for the Glood client |
Basic Usage
Advanced Usage
Error Handling
The function throws errors for invalid configurations:GloodConfig Interface
Configuration object for creating a Glood client.Properties
Property | Type | Required | Default | Description |
---|---|---|---|---|
apiKey | string | Yes | - | Your Glood API key for authentication |
myShopifyDomain | string | Yes | - | Your Shopify domain (e.g., ‘store-name.myshopify.com’) |
apps | object | No | Auto-generated | App-specific configurations |
debug | boolean | No | false | Enable debug logging |
settings | Record<string, any> | No | {} | Additional custom settings |
App Configuration
Theapps
property allows per-app customization:
Default App Configurations
Whenapps
is not provided, these defaults are used:
GloodClient Interface
The client instance returned bycreateGlood()
.
Properties
Property | Type | Description |
---|---|---|
config | GloodConfig | The configuration used to create this client |
debug | boolean | Whether debug mode is enabled |
apps | Map<AppName, GloodApp> | Map of registered app instances |
Methods
use()
Registers an app module with the client.appModuleOrFactory
: App module function or factory
getEnabledApps()
Returns all registered app instances.getApp()
Gets a specific app by name.name
: App name (‘recommendations’, ‘search’, or ‘wishlist’)
undefined
if not found
Usage:
Configuration Examples
Basic Setup
Minimal configuration with defaults:Environment-Specific Setup
Different configurations for different environments:Selective App Usage
Enable only specific apps:Custom Pixel Settings
Granular control over pixel tracking:Error Handling
The client provides comprehensive error handling:Validation Errors
Runtime Errors
Domain Validation
Best Practices
1. Environment Variables
Always use environment variables for sensitive data:2. Debug Mode
Enable debug mode in development:3. Error Handling
Wrap client creation in try-catch for production:4. Method Chaining
Use method chaining for cleaner code:See Also
- React Components - GloodProvider and hooks
- App Modules - recommendations(), search(), wishlist()
- Configuration Guide - Detailed configuration options
- Types Reference - TypeScript interface definitions