# What is the recommended approach to prevent the Builder.io API key from being exposed in the frontend when using BuilderComponent and builder.get() in a Next.js Client Component?

**URL:** <https://forum.builder.io/t/what-is-the-recommended-approach-to-prevent-the-builder-io-api-key-from-being-exposed-in-the-frontend-when-using-buildercomponent-and-builder-get-in-a-next-js-client-component/15932>\
**Category:** Technical Questions\
**Created:** [November 11, 2025, 5:48am UTC](https://forum.builder.io/t/what-is-the-recommended-approach-to-prevent-the-builder-io-api-key-from-being-exposed-in-the-frontend-when-using-buildercomponent-and-builder-get-in-a-next-js-client-component/15932 "2025-11-11T05:48:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Srivathsa1503](https://avatars.discourse-cdn.com/v4/letter/s/b19c9b/32.png) [@Srivathsa1503](https://forum.builder.io/u/Srivathsa1503)\
**Post date:** [November 11, 2025, 5:48am UTC](https://forum.builder.io/t/what-is-the-recommended-approach-to-prevent-the-builder-io-api-key-from-being-exposed-in-the-frontend-when-using-buildercomponent-and-builder-get-in-a-next-js-client-component/15932/1 "2025-11-11T05:48:08Z")

</div>

**Additional Context:**

- I understand [Builder.io](http://Builder.io) has Public (read-only) and Private (write) API keys

- My concern is whether exposing even the public read key is acceptable from a security standpoint

**What is the [Builder.io](http://Builder.io) recommended best practice for this scenario in Next.js App Router?**

---

<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:** [November 11, 2025, 9:34am UTC](https://forum.builder.io/t/what-is-the-recommended-approach-to-prevent-the-builder-io-api-key-from-being-exposed-in-the-frontend-when-using-buildercomponent-and-builder-get-in-a-next-js-client-component/15932/2 "2025-11-11T09:34:19Z")

</div>

Hello @Srivathsa1503,

You’re absolutely right to be cautious about exposing [API keys](https://www.builder.io/c/docs/using-your-api-key) in the frontend. Here’s how [Builder.io](http://Builder.io) handles this situation and what’s generally recommended:

[Builder.io](http://Builder.io) provides two types of API keys:

- **[Public (read-only) key](https://www.builder.io/c/docs/using-your-api-key):** Used to fetch published content from the Builder Content API. It’s safe to expose in the frontend since it only provides access to publicly available, published data. It cannot modify content or access drafts or unpublished models.
- **[Private (write) key](https://www.builder.io/c/docs/using-your-api-key#managing-private-keys):** Used for server-side operations such as creating, updating, or fetching unpublished content. This key should never be exposed in frontend or client-side code.

So, if you’re using `BuilderComponent` or `builder.get()` in a Next.js client component, it’s completely fine to initialize Builder with your public key. This is the expected and supported usage pattern.

That said, here are a few best practices to consider:

1. **Use environment variables:**  
Even though the public key is safe, it’s good practice to load it from an environment variable rather than hardcoding it.

2. **Avoid using private keys client-side:**  
The private key should only ever be used in server components, API routes, or backend scripts.

3. **Optional – add a proxy layer:**  
For tighter control, you can proxy Builder API requests through a Next.js API route. This can help with caching, sanitizing queries, or rate-limiting, but it’s not strictly required for security when using the public key.

In summary, exposing the public (read-only) [Builder.io](http://Builder.io) key in client-side code is safe and expected. Just make sure the private key stays strictly on the server.

> [@Builder Public key](https://forum.builder.io/t/builder-public-key/3758/2):
>
> Hello @Ankit, The way we do it is pretty standard for content management systems. Having a public key visible in API requests on the client is standard, as well as being able to fetch content with that API key. That being said, if you want to lock everything down, you can choose to make all your models private. In that case, you would need to fetch all data from the server using a private API key. Here is a forum post that talks about how to do that

Thanks,
