0

Folks,

I am looking through a Firebase blog post.

One of the items that I noticed is that they recommend (implicitly, at least) to hardcode the API keys directly into the project:

// Initialize Firebase
const firebaseConfig = {
  apiKey: "<your-api-key>",
  authDomain: "<your-auth-domain>",
  databaseURL: "<your-database-url>",
  storageBucket: "<your-storage-bucket>",,
};
const firebaseApp = firebase.initializeApp(firebaseConfig);

I was wondering if there was any way to avoid having to hard-code the API keys. If I were to do this in my project, I wouldn't be able to share it on GitHub, for example. What's the equivalent, in React Native, of setting and then retrieving an environmental variable?

Steven L.
  • 2,045
  • 3
  • 18
  • 23
  • Related question with more upvotes: http://stackoverflow.com/questions/33117227/setting-environment-variable-in-react-native – vhs Sep 22 '16 at 16:59

1 Answers1

0

Make these details as environment data and when building the project, fill firebaseConfig values from the environment data.

Or, instead of using envrionment data you can store and get the data from a password protected gist maybe.

Inanc Gumus
  • 25,195
  • 9
  • 85
  • 101
  • inanc - thank you for the reply. I am aware of environment variables in the context of web development, but not in the context of React Native. I know the "what" - set environment variables - but not the "how". I'm looking for the "how" part. – Steven L. Sep 04 '16 at 15:21