VERCEL_ENV is set to preview on custom pre-production environment

When trying to setup a new custom environment (staging), I noticed the value of VERCEL_ENV is “preview”. I was expecting the value to be the name of my new environment.

Is the intended behavior to have this variable always have the value “preview” for custom environments?

Thanks for reaching out about this, @paulyi

The feature is so new that I don’t know the answer for sure. So I asked the Custom Environments team about it and I’ll let you know what I learn.

The team just confirmed that it is expected since anything other than a production deployment is effectively a preview. But we opened a new ticket to make sure the docs say this. Thanks for pointing out that this was missing.

As a workaround, you could create an ENV environment variable for each of your environments and set the value to match the environment name. That would be fairly easy to set up in Project Settings, and then the correct environment name would be available to each new deployment.