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

Issue with private dataset in NextJS and how to handle environment variables.

2 replies
Last updated: Sep 7, 2023
Hi everyone!
I’m having issues with a private dataset in NextJS.
I can see the studio content populating my site on localhost with a public dataset, but not when I turn it to private.

I have added a SANITY_API_READ_TOKEN in my .env.local

What am I missing?
Sep 7, 2023, 7:32 PM
👋 Your Next build won’t be able to pick up Sanity-specific env vars with that prefix. That method only works in a standalone Sanity instance. You shouldcheck out the Next documentation for how best to handle it.
Sep 7, 2023, 7:56 PM
I regenerated the token and it’s all good now!
Sep 7, 2023, 8:03 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?