Accessing .env in expo

I am using create-t3-turbo template. How can I access .env file located in the root folder? I've tried this without any results:
"dev": "yarn with-env expo start --clear",
"with-env": "dotenv -e ../../.env --"
"dev": "yarn with-env expo start --clear",
"with-env": "dotenv -e ../../.env --"
4 Replies
Endgame1013
Endgame101312mo ago
Does running yarn dev not pick up the .env file? Your with-env script should pick that file up. If it doesn’t you may need to adjust the .env path (currently is ../../.env, looks like).
coado
coadoOP12mo ago
The problem is that it doesn't and I am not sure why. I know that expo only includes vars with
EXPO_PUBLIC_
EXPO_PUBLIC_
prefix, so I made a bunch of test env variables with it, but it doesn't include them.
Endgame1013
Endgame101312mo ago
I’ve personally not tried the template you’re referring to, but it looks like expo has environment variable support baked-in. Since you can only access variables prefixed with EXPO_PUBLIC_ anyway, you may just want to follow their docs and place an expo-specific .env file in the expo app’s path.
Expo Documentation
Environment variables in Expo
Learn how to use environment variables in an Expo project.
coado
coadoOP12mo ago
Yeah, that's the simplest solution. Thanks!
Want results from more Discord servers?
Add your server