# Integration with monorepo

**URL:** <https://forum.builder.io/t/integration-with-monorepo/2632>\
**Category:** Technical Questions\
**Tags:** nextjs\
**Created:** [September 20, 2022, 4:02am UTC](https://forum.builder.io/t/integration-with-monorepo/2632 "2022-09-20T04:02:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![danc222](https://avatars.discourse-cdn.com/v4/letter/d/edb3f5/32.png) [@danc222](https://forum.builder.io/u/danc222)\
**Post date:** [September 20, 2022, 4:02am UTC](https://forum.builder.io/t/integration-with-monorepo/2632/1 "2022-09-20T04:02:23Z")

</div>

**What are you trying to accomplish**  
Just trying to get up and running for now, but eventually I want to integrate builder to build a shopfront in my app

I think the issue is that my project root is a monorepo with 2 apps. Each app has a separate api folder. This is the folder structure of my project.

Root  
-----Apps  
---------App(A)-web  
--------------pages  
------------------[…page].jsx  
------------------shop.js (this is the page I want to create with [builder.io](http://builder.io))  
---------App(A)-api  
---------App(B)-web  
---------App(B)-api  
-----Shared components

Here is the what I see on the content page:

> **[screenshot](https://ibb.co/10yTRjW)**
>
> Image screenshot hosted in ImgBB

It’s successfully showing the correct page in my app, but throwing an error.

**Code stack you are integrating Builder with**  
NextJS, MongoDB, Apollo and GraphQL

Any help much appreciated!

---

<div class="post-metadata">

**Author:** ![ancheetah](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/ancheetah/32/751_2.png) [@ancheetah](https://forum.builder.io/u/ancheetah)\
**Post date:** [September 20, 2022, 9:09pm UTC](https://forum.builder.io/t/integration-with-monorepo/2632/2 "2022-09-20T21:09:04Z")

</div>

Hey @danc222 , it’s difficult to tell what is happening with out seeing your code or the page. Can you share your dynamic page template `[...page].jsx` and static `shop.js` files as well as a link to the page in Builder ([https://www.builder.io/content/{content\_id}](https://www.builder.io/content/%7Bcontent_id%7D))? A minimal reproduction with Github or Codesandbox would be even better. Thanks!

---

<div class="post-metadata">

**Author:** ![romatou](https://avatars.discourse-cdn.com/v4/letter/r/13edae/32.png) [@romatou](https://forum.builder.io/u/romatou)\
**Post date:** [August 11, 2025, 8:23am UTC](https://forum.builder.io/t/integration-with-monorepo/2632/3 "2025-08-11T08:23:45Z")

</div>

I do have the same problem with [builder.io](http://builder.io)’s Authorize access window appearing after setup. On first authorize it created an .env file with the API\_KEY in my monorepo client app and that worked. But if I delete that .env file and reload - I’ll get the authorize window again. How can I tell it explicitly to use the monorepo root .env file?

---

<div class="post-metadata">

**Author:** ![manish-sharma](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@manish-sharma](https://forum.builder.io/u/manish-sharma)\
**Post date:** [August 11, 2025, 10:26am UTC](https://forum.builder.io/t/integration-with-monorepo/2632/4 "2025-08-11T10:26:15Z")

</div>

Hello @romatou

If you’re in a monorepo and [Builder.io](http://Builder.io) keeps asking you to “Authorize access” after deleting the `.env` in your app’s package folder, here’s what’s going on:

- The [Builder.io](http://Builder.io) SDK/CLI looks for `process.env.BUILDER_API_KEY` at runtime.

- When you authorize in the UI, it creates a `.env` file **in the current working directory** (usually your package folder like `apps/client`).

- If that `.env` is deleted, the API key is gone from the environment, so the authorize window appears again.

- It doesn’t automatically check your monorepo root `.env` unless you explicitly load it.

* * *

### **Solution: Load the root `.env` from inside your app**

In your app’s config file (`next.config.js`, `nuxt.config.ts`, `vite.config.ts`, etc.), load the monorepo root `.env` using `dotenv`:

```auto
import path from 'path';
import dotenv from 'dotenv';

// Load the monorepo root .env file
dotenv.config({ path: path.resolve(__dirname, '../../.env') });

export default {
  env: {
    BUILDER_API_KEY: process.env.BUILDER_API_KEY,
  },
};

```

This way:

- You only keep one `.env` in the monorepo root.

- The client app can still access the API key.

- The [Builder.io](http://Builder.io) editor won’t trigger the authorization flow again just because the local `.env` is missing.

* * *

### **Alternative Approaches**

1. **Symlink the `.env`** from the root into the app’s folder:

2. **Set the key as a global env var** in your local shell or hosting provider:

* * *

**TL;DR:**  
[Builder.io](http://Builder.io) writes `.env` where it’s run, not in your root. If you want it to always use the monorepo root `.env`, load it explicitly in your app with `dotenv` or symlink it. This avoids repeated “Authorize access” prompts.
