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:
4 Replies
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).The problem is that it doesn't and I am not sure why. I know that expo only includes vars with prefix, so I made a bunch of test env variables with it, but it doesn't include them.
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.
Yeah, that's the simplest solution. Thanks!