This is the early access documentation preview for Custom Views. This documentation might not be in sync with our official documentation.

Deploying to Surge

This deployment example refers to Surge.

Prerequisites

Before you get started, you need to have:

Configuration

In your Custom View config, provide the Custom View ID you got when you configured the Custom View in the Merchant Center.

Moreover, you need to provide the production URL from your Surge project. You can keep the standard Surge URL https://<project>.surge.sh or provide your custom domain.

custom-view-config.mjsJavaScript
const config = {
"env": {
"production": {
"customViewId": "ckvtahxl90097sys6har1e6n3",
"url": "https://<project>.surge.sh"
}
}
// ...
}

Using environment variables

In case you want to avoid hardcoding certain values, for example the Custom View ID, or the Project key, you can use variable placeholders in your Custom View config.

custom-view-config.mjsJavaScript
const config = {
"env": {
"production": {
"customViewId": "${env:CUSTOM_VIEW_ID}",
"url": "https://<project>.surge.sh"
}
}
// ...
}

Production bundles

The main command to create the production bundles is mc-scripts build. The output folder is public, which is what is going to be uploaded to Surge.
See Going to production for more information.

To properly support client-side routing, you need to rename the index.html file to 200.html before uploading the static files.

Deploying to Surge

Use the Surge CLI to upload the static files.

surge public https://<project>.surge.sh

That's it!

Test your deployment

In the Merchant Center you can now follow the steps to install the Custom View and access it in your Projects.

The Custom View won't render if you try to access it directly via the deployment URL, as it needs to be served within the Merchant Center Proxy Router.

Therefore, Preview deployments are not really useful. If you are interested in this functionality, let us know and open a support issue.