#how to access .env from react tsx in astro?

1 messages · Page 1 of 1 (latest)

strong bloom
#

tried the search, but none of the options seem to work.

I have a .env and process.env.NEXT_PUBLIC_PROJECT_ID; to access within the .tsx, but astro does not seem to pass it. If I pass the ID directly in .tsx it works.

raven thunder
#

Note that while all environment variables are available in server-side code, only environment variables prefixed with PUBLIC_ are available in client-side code for security purposes.

#

You can access env variables using import.meta.env.<your-variable>

strong bloom
#

@stable gull thanks, I'll try this one. It's kinda weird that you have to go through so much trouble for something so basic 😭