Skip to content

init

connector.init(fn)

Used to initialize your connector.

Takes a function with an object as a parameter. The object contains the following property:

ParameterDescription
optionsObject that contains the configuration values set for options defined using defineOptions in addConnector.

The function returns an object containing initialization state that you can use throughout your connector.

connector.init(({ options }) => {
const apiClient = new CustomCMSAPIClient({
url: options.apiURL,
token: options.apiToken,
});
return {
apiClient // this will be available as state.apiClient in other connector APIs
};
});

Note that the returned state object is specific to each connector instance. If a data layer contains multiple instances of your connector, each will run its own connector.init(fn) lifecycle with the relevant configuration options for that instance and store its own state object.

Got it!

Your feedback helps us improve our docs.