# Using environment variables

**URL:** <https://answers.netlify.com/t/using-environment-variables/29615>\
**Category:** Support\
**Tags:** building, deployment\
**Created:** [January 6, 2021, 6:55pm UTC](https://answers.netlify.com/t/using-environment-variables/29615 "2021-01-06T18:55:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![bgschust](https://avatars.discourse-cdn.com/v4/letter/b/a8b319/32.png) [@bgschust](https://answers.netlify.com/u/bgschust)\
**Post date:** [January 6, 2021, 6:55pm UTC](https://answers.netlify.com/t/using-environment-variables/29615/1 "2021-01-06T18:55:18Z")

</div>

I’m trying to load the environment variable for an API key that I set using the Netlify UI, but it doesn’t seem to catch.

Is the correct syntax going to be process.env.API\_key or ${process.env.API\_key}? Can it be done without dependencies and without using the terminal?

---

<div class="post-metadata">

**Author:** ![perry](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/perry/32/16_2.png) [@perry](https://answers.netlify.com/u/perry)\
**Post date:** [January 7, 2021, 7:21pm UTC](https://answers.netlify.com/t/using-environment-variables/29615/2 "2021-01-07T19:21:49Z")

</div>

hey there, did you see this guide already?

> [@\[Support Guide\] Using environment variables on Netlify correctly](https://answers.netlify.com/t/support-guide-using-environment-variables-on-netlify-correctly/267):
>
> Last reviewed: August 2023 The preferred way to use environment variables in Netlify is to set them in our environment - be that in the Environment Variables settings UI (on the site’s “Build & Deploy settings” page), or [via netlify.toml](https://docs.netlify.com/configure-builds/file-based-configuration/). You’ll want to choose the right pattern to meet your needs. Setting variables in our UI may be considered a bit more secure, since only people with access to the Netlify admin UI for your site can see them, rather than “anyone who can clone your repo!”. Thes…

if that doesn’t help, let us know and we can dig in some more.

---

<div class="post-metadata">

**Author:** ![bgschust](https://avatars.discourse-cdn.com/v4/letter/b/a8b319/32.png) [@bgschust](https://answers.netlify.com/u/bgschust)\
**Post date:** [January 7, 2021, 8:36pm UTC](https://answers.netlify.com/t/using-environment-variables/29615/3 "2021-01-07T20:36:22Z")

</div>

Yes, I saw that and followed the links referred to in that post, but I couldn’t get any of those solutions to work.

---

<div class="post-metadata">

**Author:** ![luke](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/luke/32/39_2.png) [@luke](https://answers.netlify.com/u/luke)\
**Post date:** [January 8, 2021, 4:16am UTC](https://answers.netlify.com/t/using-environment-variables/29615/4 "2021-01-08T04:16:18Z")

</div>

Hi, @bgschust. Where are you trying to access the environment variables? For example:

- in the code that runs during the site build
- in the deployed site javascript
- in a serverless function deployed using Netlify

Knowing where you are trying to access the environment variable will help us to better answer your question.

---

<div class="post-metadata">

**Author:** ![bgschust](https://avatars.discourse-cdn.com/v4/letter/b/a8b319/32.png) [@bgschust](https://answers.netlify.com/u/bgschust)\
**Post date:** [January 8, 2021, 1:00pm UTC](https://answers.netlify.com/t/using-environment-variables/29615/5 "2021-01-08T13:00:30Z")

</div>

I’m attempting to access the environment variable in the deployed site Javascript.

---

<div class="post-metadata">

**Author:** ![Scott](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/scott/32/26136_2.png) [@Scott](https://answers.netlify.com/u/Scott)\
**Post date:** [January 8, 2021, 1:36pm UTC](https://answers.netlify.com/t/using-environment-variables/29615/6 "2021-01-08T13:36:27Z")

</div>

Hey @bgschust,

So, env vars are typically only available at build time, not once deployed:

> These variables are made available primarily in the build environment

Ideally, you’ll make use of the key during the build process and parse it at this time. There may be ways to make this available once deployed but it’ll need a bit of thought and engineering!

---

<div class="post-metadata">

**Author:** ![bgschust](https://avatars.discourse-cdn.com/v4/letter/b/a8b319/32.png) [@bgschust](https://answers.netlify.com/u/bgschust)\
**Post date:** [January 8, 2021, 1:51pm UTC](https://answers.netlify.com/t/using-environment-variables/29615/7 "2021-01-08T13:51:01Z")

</div>

I’m just trying to build something that lets me use Airtable (or Baserow or similar) as a back end. If there’s only a little bit of code I need to add to make the app work with a traditional PostgreSQL database or something similar, I’d be glad to try it.

Let’s say I want to deploy this app:  
[https://github.com/bgschust/microposts\_fullstack\_vue](https://github.com/bgschust/microposts_fullstack_vue)

Would the build command in the Netlify input box be this?  
npm install && npm start && cd client && npm run serve && cd client && npm run build

---

<div class="post-metadata">

**Author:** ![luke](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/luke/32/39_2.png) [@luke](https://answers.netlify.com/u/luke)\
**Post date:** [January 11, 2021, 1:09am UTC](https://answers.netlify.com/t/using-environment-variables/29615/8 "2021-01-11T01:09:35Z")

</div>

Hi, @bgschust. It looks like you are trying to run a server. If so, the following support guide might be helpful:

> [@\[Support Guide\] Can I run a web server, HTTP listener, and/or database at Netlify?](https://answers.netlify.com/t/support-guide-can-i-run-a-web-server-http-listener-and-or-database-at-netlify/3078):
>
> Last reviewed: July 2025 How do I run a server/database at Netlify? We often get questions about how to run a specific backend server or database at Netlify. Examples of these types of questions include: How to I get my node HTTP listener to respond to requests? How do I start Mongo/MySQL/\<insert-some-database-here\> running on the server? How can I SSH into my website? We are here today to answer these questions - and the answer is: you can’t! hushed_faceWhat do you mean, I cannot run a …

It might be possible to adapt the server process to run as a serverless function but you cannot just “run a server” at Netlify. The [Jamstack](https://jamstack.org/) design philosophy doesn’t use a traditional [application server](https://en.wikipedia.org/wiki/Application_server).

---

<div class="post-metadata">

**Author:** ![bgschust](https://avatars.discourse-cdn.com/v4/letter/b/a8b319/32.png) [@bgschust](https://answers.netlify.com/u/bgschust)\
**Post date:** [January 11, 2021, 2:35am UTC](https://answers.netlify.com/t/using-environment-variables/29615/9 "2021-01-11T02:35:22Z")

</div>

Thanks for the reference, it looks thorough and well thought-out, but I was hoping there would be a simple solution to deploy an existing project just to see how much time I’d have to spend on DevOps tasks. It sounds like there will be a lot of steps if I take that route instead of basic API requests. Minimizing server tasks for a web project would be ideal.

Thank you for your assistance.
