openmobilehub / react-native-omh-auth

https://openmobilehub.github.io/react-native-omh-auth/
Apache License 2.0
0 stars 0 forks source link

Suggestion to Use `@env` from `react-native-dotenv` for Environment Variables #60

Closed dzuluaga closed 1 month ago

dzuluaga commented 1 month ago

I've been encountering intermittent issues with accessing environment variables using process.env in my React Native project. Despite having variables set in the .env file, the application does not recognize them and throws errors.

Observation: It seems that process.env is not the most reliable method for accessing environment variables in React Native. This method often leads to issues, possibly due to caching or other environment-specific reasons.

Proposed Solution: I switched to using @env from the react-native-dotenv package and found it to be a more idiomatic and reliable approach. This change resolved all issues related to accessing environment variables.

Recommendation: Consider adopting the @env approach from react-native-dotenv for handling environment variables. It aligns better with React Native’s ecosystem and improves reliability.

Thank you for considering this suggestion.

Esemesek commented 1 month ago

Hey @dzuluaga, I think this is outside of the scope of this project/library as we leave it to the users how they provide secret values to their applications. When it comes to our sample app we are already using react-native-dotenv and following one of the techniques mentioned in the library (https://www.npmjs.com/package/react-native-dotenv#processenv-technique).

dzuluaga commented 1 month ago

Thanks @Esemesek. I've recloned the repo and can't repro the issue. I see there's a commit in flight by Andrei. Will keep an eye on it.

andrei-zgirvaci commented 1 month ago

Hey @dzuluaga, thanks for bringing this to our attention! This has been addressed and should be fixed in https://github.com/openmobilehub/react-native-omh-auth/pull/63/commits/63a16f4e5f70226c352d1ba765f25ff359f0e633.

We have also improved the documentation in https://github.com/openmobilehub/react-native-omh-auth/commit/788538f588d0099ea2ea7ae923ae7007afeae273, so developers won't need necessarily to store their secrets in a .env file, leaving it up to them to decided how to pass those values to our API.