👀 Our most exciting product launch yet 🚀 Join us May 8th for Sanity Connect

How to Insert Environment Variables in a JSON Config

8 replies
Last updated: Sep 29, 2021
How do you insert environment variables in a .json config?
Sep 27, 2021, 1:03 AM
I think we need some more context here… The value of the env var or the name of it to be resolved later?
One of the main things about using env vars is that they are not stored on disk.
Sep 27, 2021, 9:16 AM
For development I wanted to put it in a
.env
file
Sep 27, 2021, 2:46 PM
I just don't want to store it in the .json file
Sep 27, 2021, 2:46 PM
Hey Max! What are you looking to put into an env file? There's some information on using env vars here , but I could possibly give you more specific advice if I knew more about the use case!
Sep 27, 2021, 5:25 PM
I don't want the tokens in a public repo
Sep 28, 2021, 9:35 PM
You'll have to use one of the methods described here if you're trying to obscure your tokens.
Sep 28, 2021, 11:28 PM
How do I do this with the .json config? Is there something I can do to add environment variables to a config?
Sep 29, 2021, 1:16 AM
config/@sanity/google-maps-input.json
has a key
apiKey
which I want it to be a environment variable.
Sep 29, 2021, 1:27 AM

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?