Context name for Netlify Dev

Is there a context to be refered to in netlify.toml for Netlify Dev (alongside production, deploy-preview etc…)?

Hi, @regisphilibert. First, I want to mention that Netlify Dev is a beta at this time and there are more than a few open issues and feature requests.

The only the build environment variables are picked up by netlify dev at this time. It is an open feature request to support context specific environment variables.

It’s on our todo list but not available yet.

1 Like

Hey there, I know this post is a couple years old so wanted to check to see if this feature is available yet?

From what I’ve been trying, it doesn’t seem so, but just wanted to throw the question out there.

I have two separate databases I’d like to run netlify dev on, configuring API keys via netlify.toml.

Like netlify dev --context staging

Thanks

Hi @proton,

Netlify Dev uses .env file to load environment variables. In most cases, that file is not committed to the repo. So, you can use your local secrets in that .env file. Does that work for your use case?

It would be useful to be able to tap into different contexts for dev in addition to build, but I understand that’s not a feature. I can comment/uncomment within .env. Just wanted to clarify. Thanks

Hi @proton,

I suggested .env file because I thought it’s easier. But the feature very much exists. You could use something like:

[context.dev.environment]
  ENV_VAR = "foo"

Thanks @hrishikesh, it’s good to know that this works. However, in my case, I’m wondering if there’s a way to have the dev process pull from different environments, like:

dev - database 1
dev - database 2

Currently I just comment / uncomment the same set of env variables within .env which is okay too.