.env
files must be suffixed with either .development
or .production
in order for Sanity to use them. The environment suffix is determined by the following:
process.env.SANITY_ACTIVE_ENV
takes precedenceprocess.env.NODE_ENV
is fallback- if neither of the above are defined, then
development
is using forsanity start
andproduction
is used forsanity build
andsanity deploy
.
Also, in sanity.json
, the following properties must be defined, even when using env vars:
"api": {
"projectId": "thiscannotbeemptyevenwhenusingenvvarsotherwisesanityisnothappy",
"dataset": "mustbe20charsorless"
},
When using env vars, the projectId
and dataset
id values can be any arbitrary value as they are overridden by env vars. However, the dataset
value must be 20 characters or less to pass Sanity validation.
SANITY_STUDIO_API_PROJECT_ID=
SANITY_STUDIO_API_DATASET=