Netlify: Deploy Multiple React Repositories on a Single Site

I build static sites with Jekyll because its simple and file-backed.

I build dynamic sites with React because its simple and deterministic.

Sometimes we find a need to deploy a react application inside of jekyll, and its main drawback is locally building/committing the build each time you want to deploy.

Just like if you were sprinkling jquery into a regular website, you have to deploy the assets.

Below we have a solution to use netlify redirects/rewrites, as a way to reverse proxy a subdirectory path onto the index of another netlify project.

That netlify project can be build from a separate repo, or from another folder in a mono-repo style.

Root Repo App

Setup two redirects:

It is important the redirects are in this order, because proxies are processed in order.

Child folder Repo App

add environment variable for PUBLIC_URL=/subdir

This tells Create-React-App that the target will be hosted on a sub-folder

You can also use process.env.PUBLIC_URL as a basename for react-router!

Blair Anderson is the creator of Tachyons Templates.


Blog Posts

Template Categories