# Where to put .env file in CMS-React-Boilderplate?

**URL:** <https://community.hubspot.com/t/where-to-put-env-file-in-cms-react-boilderplate/32077>\
**Category:** CMS Development\
**Tags:** javascript\
**Created:** [February 22, 2021, 5:43am UTC](https://community.hubspot.com/t/where-to-put-env-file-in-cms-react-boilderplate/32077 "2021-02-22T05:43:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SaraRandolph](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sararandolph/32/98942_2.png) [@SaraRandolph](https://community.hubspot.com/u/SaraRandolph)\
**Post date:** [February 22, 2021, 5:43am UTC](https://community.hubspot.com/t/where-to-put-env-file-in-cms-react-boilderplate/32077/1 "2021-02-22T05:43:07Z")

</div>

I am working with a custom version of [CMS-React-Boilderplate](https://github.com/HubSpot/cms-react-boilerplate) and I’m having a hard time accessing any .env variables. I’ve created a `.env` file in my root directory and I have tried access it with `process.env.REACT_APP_…` without any success. Has anyone had any sucess using a `.env` file with hubspot?

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [February 22, 2021, 6:11pm UTC](https://community.hubspot.com/t/where-to-put-env-file-in-cms-react-boilderplate/32077/2 "2021-02-22T18:11:43Z")

</div>

Heyo @SaraRandolph !

Tagging in @Kevin-C and @kierana to get some help here 😀

---

<div class="post-metadata">

**Author:** ![kierana](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kierana/32/44503_2.png) [@kierana](https://community.hubspot.com/u/kierana)\
**Post date:** [February 22, 2021, 6:19pm UTC](https://community.hubspot.com/t/where-to-put-env-file-in-cms-react-boilderplate/32077/3 "2021-02-22T18:19:25Z")

</div>

To use process.env you’re going to need to use the EnvironmentPlugin, if you want to use .env you’ll need to use [https://www.npmjs.com/package/dotenv-webpack](https://www.npmjs.com/package/dotenv-webpack)

I’m guessing you’re used to using create-react-app - the CMS React Boilerplate doesn’t use CRA.

---

<div class="post-metadata">

**Author:** ![Kevin-C](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kevin-c/32/34570_2.png) [@Kevin-C](https://community.hubspot.com/u/Kevin-C)\
**Post date:** [February 22, 2021, 6:38pm UTC](https://community.hubspot.com/t/where-to-put-env-file-in-cms-react-boilderplate/32077/4 "2021-02-22T18:38:00Z")

</div>

Thanks @dennisedson

Hey @SaraRandolph not sure how much help I can bring to the table here as I haven’t used env variables with the cms boiler.

But have you tested in other environments? This seems to be a common issue with the env variables.

To expand I’m not sure if the CMS boiler is configured to use the env variables. I’d imagine it would be but you know what happens when you assume lol.

In an attempt to not leave you empty handed I did find these links that may help you trouble shoot:

[create-react-app docs](https://create-react-app.dev/docs/adding-custom-environment-variables/)

[more of the same with another test method](https://functional.works-hub.com/learn/create-react-app-run-time-vs-build-time-environment-variables-67f01)

---

<div class="post-metadata">

**Author:** ![SaraRandolph](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sararandolph/32/98942_2.png) [@SaraRandolph](https://community.hubspot.com/u/SaraRandolph)\
**Post date:** [February 23, 2021, 5:25am UTC](https://community.hubspot.com/t/where-to-put-env-file-in-cms-react-boilderplate/32077/5 "2021-02-23T05:25:13Z")

</div>

Thank you both! I ended up using the dotenv-webpack package and putting it in my webpack.config.js. Thanks for your help 🙂
