Skip to main content

setCustomURLsBuilder()

setCustomURLsBuilder(customURLsBuilder): Promise<Success>

The setCustomURLsBuilder method allows you to provide custom URL builders for product, collection, and login pages. Use this on custom storefronts where Shopify's standard URL structure (/products/<handle>, /collections/<handle>, /account/login) does not apply.

When set, all three builder methods are used by Growave widgets in place of the default Shopify URL builders.

Parameters​

ParameterTypeDescription
customURLsBuilderCustomURLsBuilderInterfaceAn object implementing the CustomURLsBuilderInterface interface.

Returns​

Promise<Success>

Example​

Ensure the SDK is ready before setting the custom URLs builder.

function onSdkReady() {
window.gw.sdk.common.methods.setCustomURLsBuilder({
createProductUrl({ productHandle, variantId, productId }) {
const url = `/p/${productHandle}`;
return variantId ? `${url}?variant=${variantId}` : url;
},
createCollectionUrl({ collectionHandle, collectionId }) {
return `/c/${collectionHandle}`;
},
createStorefrontLoginUrl() {
return "/custom-auth-url";
},
});
}

if (window.gw && window.gw.sdk) {
onSdkReady();
} else {
document.addEventListener("gwSdkReady", onSdkReady);
}