Use Netlify environment variables during local development

Jason Lengstorf
InstructorJason Lengstorf
Share this video with your friends

Social Share Links

Send Tweet
Published 4 years ago
Updated 3 years ago

Run Netlify Functions locally with access to environment variables using Netlify Dev.

Jason Lengstorf: [0:00] A really convenient way to develop with Netlify functions is to be able to run them locally, but when you're using environment variables, it can be kind of challenging to do that. Fortunately, Netlify Dev allows us a way to set environment variables in Netlify's dashboard and then use them locally.

[0:15] To show you how this works, we're going to log in to stripe, go to our dashboard, and we're Viewing test data. We're going to go into Developers and then we'll go to API keys and we want to grab our publishable key and our secret key.

[0:33] We're going to keep this open for a second, because next we're going to go to and we're going to open up the stripe-checkout-netlify-serverless site that we just created. I'm going to go to Deploys and then Deploy settings. Down here, we can see our environment variables for this site.

[0:53] I want to create two environment variables. The first one is going to be called STRIPE_PUBLISHABLE_KEY. The next one is going to be called STRIPE_SECRET_KEY.

[1:06] If I go back over, I can copy this value for the publishable key, and then I can reveal the secret key, copy that value and paste it in here. Then I can save that and now we've got our publishable key and our secret key saved in Netlify.

[1:29] If I come out and run ntl dev, we can see that now the publishable key and the secret key have been brought in by Netlify Dev so we can develop with those values set.

~ 35 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today