# Deploy to Netlify Learn how to deploy your customization to [Netlify](https://www.netlify.com/). ## Prerequisites Before you get started, you need to have: - A [Netlify](https://app.netlify.com/) account. - A Project - A Merchant Center account, or an [Identity account](/docs/identity/overview.md) - A customization configured in the Merchant Center: - For Custom Applications, see [Managing Custom Applications](/merchant-center/managing-custom-applications.md). - For Custom Views, see [Managing Custom Views](/merchant-center/managing-custom-views.md). ## Configuration ### Add 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 from your Netlify site. You can keep the standard Netlify URL `https://.netlify.app` or provide your custom domain. For Custom Applications, make the following changes to the [Custom Application config](/merchant-center-customizations/tooling-and-configuration/custom-application-config.md): - Add the Custom Application ID to [`env.production.applicationId`](/merchant-center-customizations/tooling-and-configuration/custom-application-config.md#envproductionapplicationid). - Add the production URL of your Netlify site to [`env.production.url`](/merchant-center-customizations/tooling-and-configuration/custom-application-config.md#envproductionurl). ```json title="custom-application-config.json" { "env": { "production": { "applicationId": "ckvtahxl90097sys6har1e6n3", "url": "https://.netlify.app" } } } ``` For Custom Views, make the following changes to the [Custom View config](/merchant-center-customizations/tooling-and-configuration/custom-view-config.md): - Add the Custom View ID to [`env.production.customViewId`](/merchant-center-customizations/tooling-and-configuration/custom-view-config.md#envproductioncustomviewid). - Add the production URL of your Netlify site to [`env.production.url`](/merchant-center-customizations/tooling-and-configuration/custom-view-config.md#envproductionurl). ```js title="custom-view-config.mjs" const config = { env: { production: { customViewId: 'ckvtahxl90097sys6har1e6n3', url: 'https://.netlify.app', }, }, // ... }; ``` ### Use 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](/merchant-center-customizations/tooling-and-configuration/custom-application-config.md#use-variable-placeholders) or [Custom View config](/merchant-center-customizations/tooling-and-configuration/custom-view-config.md#use-variable-placeholders). Example of environment variables with Custom Applications: ```json title="custom-application-config.json" highlightLines="4" { "env": { "production": { "applicationId": "${env:APPLICATION_ID}", "url": "https://.netlify.app" } } } ``` Example of environment variables with Custom Views: ```js title="custom-view-config.mjs" highlightLines="4" const config = { env: { production: { customViewId: '${env:CUSTOM_VIEW_ID}', url: 'https://.netlify.app', }, }, // ... }; ``` ## Connect Netlify with GitHub The easiest way to deploy to Netlify is to use the [GitHub integration](https://docs.netlify.com/configure-builds/overview/). Follow the steps in Netlify to create and import a new Git repository. Make sure to also install the [Netlify GitHub App](https://github.com/apps/netlify) to grant access to your repository. ### Configure build settings In the [Netlify setup process](https://docs.netlify.com/configure-builds/overview), 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: ```json title="package.json" { "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](/merchant-center-customizations/deployment/netlify.md#use-environment-variables), make sure to provide them in your **Netlify site > Settings > Build & deploy > Environment**. ### Configure rewrite rules A customization is a Single-Page Application that uses client-side routing. Therefore, we need to [instruct Netlify](https://docs.netlify.com/routing/redirects/rewrites-proxies/#history-pushstate-and-single-page-apps) 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: ```toml title="netlify.toml" [[redirects]] from = "/*" to = "/index.html" status = 200 ``` ## Test your deployment Install your customization in the Merchant Center to access it within your Projects: - For Custom Applications, see [Managing Custom Applications](/merchant-center/managing-custom-applications.md). You can also use [deployment previews](/merchant-center-customizations/concepts/deployment-previews.md) to test the application before releasing it to the production environment. - For Custom Views, see [Managing Custom Views](/merchant-center/managing-custom-views.md). ## Related pages - [Area overview page with navigation](/merchant-center-customizations.md) - [Previous page: Deploy to Vercel](/merchant-center-customizations/deployment/vercel.md) - [Next page: Deploy to Render](/merchant-center-customizations/deployment/render.md)