Skip to content

How to import data from a .env file in TypeScript project? #3583

Discussion options

You must be logged in to vote
  1. You will need to add a .env file with the config.
  2. V3 is using Vite which exposes a special object with the env variables. So all places you would normally do a process.env.* you will need to do import.meta.env.* to access the variables.
export default createConfig({
  projectId: import.meta.env.SANITY_STUDIO_API_PROJECT_ID
})

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@unitof
Comment options

Answer selected by kmelve
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants