How to reference Firebase Functions config variables from a Firebase-hosted application?


I am transitioning a Heroku-hosted ReactJS/NodeJS application to be hosted on Firebase. Because Firebase only handles static pages I need to reconfigure how my private environmental-specific variables for Development, Staging, Production environments are configured. For example before I defined these sorts of variables:

CLIENT_ID=secret_here DOMAIN=secret_here REDIRECT_URI=secret_here

upon the Heroku environment I was deploying to and now I must set them into firebase functions environments from the Firebase CLI for Dev, Staging and Production.

Firebase has documentation on <a href="https://firebase.google.com/docs/functions/config-env" rel="nofollow">adding environmental configurations to Firebase Functions</a> such that I can add key/value pairs to be accessed at runtime from within a firebase <strong>function</strong>:

firebase functions:config:set mySecret.key="CLIENT_ID" mySecret.id="secret_here"

however <strong>I am unclear how added configuration variables can be accessed from Firebase-hosted static applications (rather than functions).</strong>

Is it as simple as simply referencing the firebase functions library from my application and retrieving the defined key from within my application (like so)?

const functions = require('firebase-functions'); ... functions.config().auth0.CLIENT_ID


The variables you define through the link you provided are only available via Cloud Functions. They're not made available directly to the static content served by Firebase Hosting.

If you want, you can make an HTTP function that does nothing but return the JSON from your env vars, and call that from your web content. Bear in mind that you're exposing your secret keys to the world.


The best practice way to handle what I am trying to do is to refactor all of the application logic requiring environment configuration into firebase functions. I can then invoke said functions to reference environment config and execute the code consuming them. This is the answer/solution I needed and didn't have the context to realize earlier. thanks for edging me towards that realization.


  • FB.login Invalid redirect_uri (xd_proxy.php)
  • TypeError upon authenticating user using Google OAuth 2
  • How to get email address along with people list in google plus API
  • Cannot update firebase version [duplicate]
  • Firebase firestore cloud functions showing trigger type 'unknown'
  • Google OAuth2 for an web application hosted behind NAT (intranet server without public IP)
  • How do I configure Maven Cargo to use an embedded Tomcat server?
  • Firebase, only get new children
  • UML diagram generator in Visual Studio 2010
  • How could I prohibit anonymous access to my NodeRed UI Dashboard on IBM Cloud(Bluemix)?
  • Hiding Directories Programatically in C#
  • Loading fixtures in sails tests
  • What is the use of a session store?
  • How to skip require in ruby?
  • New Firebase failed: First argument must be a valid firebase URL and the path can't contain “.”
  • opencv display image without x server
  • jwtBearer bearer token with rc-1 update to ASP.Net 5
  • Saving image to sd with current date and time in name doesn't work
  • perl, mysql - fasting way to upload a csv file into mysql?
  • How do I include a SWC in an AS2 Flash project?
  • How to add a focus style to an editable ComboBox in WPF
  • How do I superscript characters in a UIButton?
  • Should I or shouldn't I use the CachingConnectionFactory with hornetq 2.4.1
  • Installing iPhone App to iPhone
  • Installing Apache MyFaces 2 on WildFly 8.2.0
  • Email verification using google app script and google forms
  • Yii2: Config params vs. const/define
  • Installing Hadoop, Java Exception about illegal characters at index 7?
  • Is my CUDA kernel really runs on device or is being mistekenly executed by host in emulation?
  • Java applet as stand-alone Windows application?
  • output of program is not same as passed argument
  • Does CUDA 5 support STL or THRUST inside the device code?
  • Statically linking a C++ library to a C# process using CLI or any other way
  • Jquery - Jquery Wysiwyg return html as a string
  • Why winpcap requires both .lib and .dll to run?
  • 0x202A in filename: Why?
  • Arrays break string types in Julia
  • SQL merge duplicate rows and join values that are different
  • How do you join a server to an Active Directory (domain)?
  • Reading document lines to the user (python)