Creating a new client instance in XGEN involves initializing the SDK with your API credentials, environment settings, and optional authentication store, giving you a single, reusable connection point for calling services like Search, Recommend, and Tracking throughout your application.
These can be found in your Admin Dashboard
const xg = new XGenClient({
key: '<your_api_key>',
secret: '<your_api_secret>',
clientId: '<your_client_id>',
trackerId: '<your_tracker_id>',
getEnv: () => 'stage', // optional: function that returns the environment (`stage` or `prod`) - defaults to 'prod'
authStore: new LocalCookieAuthStore() // optional - can pass in a custom auth store instance - defaults to LocalCookieAuthStore
});