Authentication module
The Authentication module initializes after the SDK but before any specific Growave applications. To ensure your code runs when the Authentication module is ready, use the runIfModuleReady method available immediately after the gwSdkReady event is triggered.
This method ensures your callback runs immediately if the Authentication module is initialized; if not, it runs once the module is ready.
The Authentication module is crucial for initializing custom storefronts. It provides the authentication mechanisms needed for secure interactions with Growave services. For more details on setting up a custom storefront, refer to the Custom storefront documentation.
function onSdkReady() {
const moduleName = window.gw.sdk.common.constants.modules.AUTHENTICATION;
window.gw.sdk.runIfModuleReady(moduleName, () => {
// The Authentication module is ready to use and available at `window.gw.sdk.authentication`
});
}
if (window.gw && window.gw.sdk) {
onSdkReady();
} else {
document.addEventListener("gwSdkReady", onSdkReady);
}