Monorepo + shared build environment variables

Hello Netlify Support Team & community!

I could not find documentation or write ups of this being done, but I was wondering if there was way to share or query build environment variables of other Netlify application deployments or applications in same monorepo. I’ll try to clarify below.

The reasoning: I have one Netlify application that acts as a CMS and the other a Frontend.
The CMS is able to pull in the frontend application in an SPA mode to do live previews of the content in production or any branch context deploy.

However being that the CMS UI is statically generated itself ( , and it needs access to the appropriate DEPLOY_URL or DEPLOY_PRIME_URL in order to resolve the correct preview URL’s for the iframe which shows the preview. From my understanding those URL build variables are dynamic is some form when using a specific context.

Is there a way I can maybe use redirects? This is first thing that comes to mind as a low cost solution, but I am not sure how I’d get access to the those same BUILD env vars for this to work.

It would be useful to get access to other build envs in order to programmatically generate deployments that can work in sync. I feel like this is possible, and I am just missing it somewhere. A build plugin?

Relevant side note: I just learned that Netlify Dev can only do local dev for one site at a time. Making it’s uses for monorepo limited and not able to solve my case here as I thought it might be able to.

Any clarity on this would be greatly helpful

The DEPLOY_URL and DEPLOY_PRIME_URL become public as soon as the deploy is published. Would it be possible for you to publish one site first, then grab those URLs to use in the second site’s deploys? Another weird idea is to build a Build Plugin that onEnd or onSuccess triggers the other site’s build, passing along the first site’s DEPLOY_URL/DEPLOY_PRIME_URL to use however you want.

1 Like

Thank you for the response first, and secondly, that sounds like a great idea.
I just wanted to have the inkling of an idea that it might be possible.

I will try to report back my trials and tribulations.
Thank you!

1 Like