Watch a live product demo 👀 See how Sanity powers richer commerce experiences

Hi, Can someone tell me the proper way to enter the projectID using ENV’s in the sanity.json. If I hard code, works great, anything else and and it’s not finding the projectId....

8 replies
Last updated: Jan 24, 2021
Hi, Can someone tell me the proper way to enter the projectID using ENV’s in the sanity.json. If I hard code, works great, anything else and and it’s not finding the projectId. ENV’s are in .env.local
"api": {
    "projectId": "PLACEHOLDER_ENV_VARIABLES_WILL_HANDLE_FOR_US",
    "dataset": "PLACEHOLDER_ENV_VARIABLES_WILL_HANDLE_FOR_US"
  }
Jan 6, 2021, 5:17 PM
They need to be in studio folder and be named
.env.development
and
.env.production
I think
Jan 6, 2021, 5:22 PM
and should not be referenced in sanity.json file like that. you can delete the api section
Jan 6, 2021, 5:23 PM
ok thanks, I’ll give that a go
Jan 6, 2021, 5:28 PM
https://www.sanity.io/docs/studio-environment-variables#dot-env-files-env-f5e9e3158896 here you can read a bit more about how they should me named etc
Jan 6, 2021, 5:31 PM
Makes sense, production is working, it’s just localhost that is not finding the project ID. I put in the studio folder
Jan 6, 2021, 5:33 PM
Nice, that’s all it was. Cheers
user T
Jan 6, 2021, 5:36 PM
Hey guys, I am facing the same problem, and I followed the instructions of
user T
(removed the api section from sanity.json), and I placed a .env.development in the root folders with the variables SANITY_STUDIO_API_PROJECT_ID and SANITY_STUDIO_API_DATASET defined.However, when I run sanity start, sanity says "Project configuration required before starting studio" and forces me to select a project or create a new one ...

Any ideas how I could fix that?
Jan 23, 2021, 10:45 AM
(found the answer thanks to
user Q
, commented here: https://sanity-io-land.slack.com/archives/C9Z7RC3V1/p1611482229244200 )
Jan 24, 2021, 12:37 PM

Sanity.io – build remarkable experiences at scale

Sanity is a customizable solution that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Categorized in

Related answers

Get more help in the community Slack

TopicCategoriesFeaturedRepliesLast Updated
After adding the subtitle and running this code npm run graphql-deploy It does nothingSep 15, 2020
how to limit a reference to just one entry in Studio reference input side versus the default as-many-entries-as-you-fill-in-an-array...Sep 18, 2020
Is it possible to fetch more than one "_type" using GROQ?Nov 2, 2020
I want to add a view with the Structure builder (S.view.component) where I list similar documents based on the title. What...Sep 23, 2020
Is there a structure builder example where the format of each preview for the document list is modified?Feb 3, 2021
I have an array of references to a country schema type but it always just returns NULL values for meJan 30, 2021
Hi, I need help with a query for getting the url of an image asset. Here is what I've been trying, but I only get the _ref...Dec 1, 2020
Sanity UI looks brilliant :smiley: Is something like the current date picker possible at the moment? I’m not sure if anicon...Dec 21, 2020
Hey everyone. I have been coding and may have potentially accidentally deleted something. Does anyone know how to resolve...Dec 26, 2020
Hello everyone and happy new year :raised_hands::skin-tone-2:, I have a problem with outputting Portable Text :disappointed:...Jan 1, 2021

Related contributions

Clean Next.js + Sanity app
- Template

Official(made by Sanity team)

A clean example of Next.js with embedded Sanity ready for recomposition.

Cody Olsen
Go to Clean Next.js + Sanity app

Blog with Built-in Content Editing
- Template

Official(made by Sanity team)

A Sanity-powered blog with built-in content editing and instant previews.

Go to Blog with Built-in Content Editing