Deploy to Render

Learn how to deploy your customization to Render.

Prerequisites

Before you get started, you need to have:

Configuration

Adding the customization identifier and URL

Depending on the customization type, you'll need to specify either the Custom Application ID or the Custom View ID that was provided to you when you added the customization in the Merchant Center.

You'll also need to specify the production URL of your Render site. You can keep the standard Render URL https://<site>.onrender.com or provide your custom domain.

For Custom Applications, make the following changes to the Custom Application config:

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

For Custom Views, make the following changes to the Custom View config:

custom-view-config.mjsJavaScript
const config = {
env: {
production: {
customViewId: 'ckvtahxl90097sys6har1e6n3',
url: 'https://<site>.onrender.com',
},
},
// ...
};

Using environment variables

To avoid hardcoding values (such as the customization identifier or the Project key), you can use variable placeholders in your Custom Application config or Custom View config.

Example of environment variables with Custom Applications:

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

Example of environment variables with Custom Views:

custom-view-config.mjsJavaScript
const config = {
env: {
production: {
customViewId: '${env:CUSTOM_VIEW_ID}',
url: 'https://<site>.onrender.com',
},
},
// ...
};

Connect Render with GitHub

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

Follow the steps in Render to create a new static site and import a new Git repository.

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

Configuring build settings

In the Render 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 Publish directory with: public.

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

If your customization config requires environment variables, make sure to provide them in your Render site > Environment.

Configuring rewrite rules

A customization is a Single-Page Application that uses client-side routing. Therefore, we need to instruct Render to rewrite all requests to serve the index.html.

/* --> /index.html

Test your deployment

Install your customization in the Merchant Center to access it within your Projects: