No way to have separate environment variables for production and netlify dev?

I’m trying to use Netlify functions for a post checkout stripe hook. However, I can only test if I set my environment variables in the web console to the test keys from stripe. Unfortunately, there’s no way to separate development environment variables from production environment variables. If I want to test changes to my cart in development I essentially have to disable checkout on my site while I do so.

Am I missing something?

hello! no you are not missing anything. this is a top request for us. you can follow

and

and

to track this. for now you’ll have to use a conditional like process.env.NODE_ENV != 'production' ? 'DEV_ENV_VAR' : 'PROD_ENV_VAR' or something similar for your env vars (i know its not great but its not a deal breaker either). thanks for your patience while we sort this out.

While Shawn, Chris and the other great devs at Netlify solve this issue, you do have an option that takes a little to get your head around.

  • Make a new branch we will call testing (for example).
  • Go to app.netlify.com and create a new site using the repository.
  • Setup the environment variables to the stripe test keys
  • Setup this site to have the Production branch (not really production) as testing

The testing branch might not be needed in this case, but might be a good workflow for site change tests also prior to a pull request.

Note: There might be some issues with domain resolution. Those might be a hindrance to this solution.