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

Deploying to AWS with S3 and CloudFront

This deployment example refers to AWS static hosting using an S3 bucket and CloudFront distribution.

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 CloudFront site. You can keep the standard CloudFront URL https://<site>.cloudfront.net or provide your custom domain.

custom-view-config.mjsJavaScript
const config = {
"env": {
"production": {
"customViewId": "ckvtahxl90097sys6har1e6n3",
"url": "https://<site>.cloudfront.net"
}
},
// ...
}

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://<site>.cloudfront.net"
}
}
// ...
}

Set up S3 and CloudFront

To host the production bundles of your Custom View you need to create some resources in AWS, like an S3 bucket, configure a CloudFront distribution, etc.

A Custom View is set up in a very similar way as a Create React App. Therefore, we recommend checking out other articles about configuring AWS for static hosting for more detailed explanations about the setup.

Production bundles

The main command to create the production bundles is mc-scripts build. The output folder is public.
See Going to production for more information.

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.