#how to access .env from react tsx in astro?
1 messages · Page 1 of 1 (latest)
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>
that won't work in .ts .js
in this example https://github.com/MicroWebStacks/astro-examples/tree/main#07_env-config I had to import env vars myself with dotenv then it works https://github.com/MicroWebStacks/astro-examples/blob/2fe418839d75183bc41f76558f2c566e6896a98c/07_env-config/src/pages/server.js#L4
@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 😭