🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

Setting up environment variables in Sanity Studio Next.js app for deployment

6 replies
Last updated: Jun 13, 2023
Hi! I am using the .env environment to save my Project ID. it works fine locally but when I try to deploy it to sanity, the ID is empty. How can I set up the .env values in SAnity so I can read all variables?Thanks
Jun 13, 2023, 9:19 AM
Are you deploying it on Vercel? have you provided the env variable to the hosting too?
Jun 13, 2023, 9:32 AM
I am deploying it to Netlify, and it works fine. I need it in Sanity Studio
Jun 13, 2023, 9:33 AM
Next js app?
Jun 13, 2023, 9:35 AM
I will try it, Thanks!
Jun 13, 2023, 9:37 AM
As far as I remember ENV must start with NEXT_PUBLIC in Nextjs
Jun 13, 2023, 9:37 AM
I'm pretty sure you can name the environment variables whatever you want. NEXT_PUBLIC_ is just the convention they used. What are you trying to do exactly? If you're trying to get Next.js setup with Sanity, there are several repos , guides , and youtube videos available that walk you through the configuration process.
Jun 13, 2023, 5:36 PM

Sanity– build remarkable experiences at scale

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

Was this answer helpful?