Deploying to Netlify

This deployment example refers to Netlify.

Prerequisites

Before you get started, you need to have:

Configuration

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

Moreover, you need to provide the production URL from your Netlify site. You can keep the standard Netlify URL https://<site>.netlify.app or provide your custom domain.

custom-application-config.jsonjson
{
"env": {
"production": {
"applicationId": "ckvtahxl90097sys6har1e6n3",
"url": "https://<site>.netlify.app"
}
}
}

Using environment variables

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

custom-application-config.jsonjson
{
"env": {
"production": {
"applicationId": "${env:APPLICATION_ID}",
"url": "https://<site>.netlify.app"
}
}
}

Connect Netlify with GitHub

The easiest way to deploy to Netlify is to use the GitHub integration.

Follow the steps in Netlify to create and import a new Git repository.

Make sure to also install the Netlify GitHub App to grant access to your repository.

Configuring build settings

In the Netlify setup process you need to configure the following things:

  • Override the Build command with: yarn build.

    In your package.json make sure to have the following scripts defined:

    package.jsonjson
    {
    "scripts": {
    "build": "mc-scripts build"
    }
    }
  • Override the Output directory with: public.

  • If possible, select or specify the Node.js Version. Recommended version is >= v14.

If your Custom Application config requires environment variables, make sure to provide them in your Netlify site > Settings > Build & deploy > Environment.

Configuring rewrite rules

A Custom Application is a Single-Page Application that uses client-side routing. Therefore, we need to instruct Netlify to rewrite all requests to serve the index.html. For this purpose, create netlify.toml file in the root directory of your project with the following content:

netlify.tomltoml
[[redirects]]
from = "/*"
to = "/index.html"
status = 200

Test your deployment

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

The Custom Application 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.