title: How do I use the same firebase database in multiple HTML pages?
body: <p>I'm creating an app that has a dashboard, this dashboard links to different HTML pages that do different stuff that requires updating my firebase database, with a single page app I can do this without issue, issue comes when I try to do it with multiple pages</p>
  
  <p>When I try to connect to the database from dashboard_2.html it says that the app already exists (because I already called it from index.html from database.js), if I remove the configuration part from the js file and just let the modify part it says that no firebase app has been created.</p>
  
  <p>index.html</p>
  
  <pre><code>    &lt;script src="https://www.gstatic.com/firebasejs/ui/3.6.1/firebase-ui-auth__es.js"&gt;&lt;/script&gt;
      &lt;link type="text/css" rel="stylesheet" href="https://www.gstatic.com/firebasejs/ui/3.6.1/firebase-ui-auth.css" /&gt;
      &lt;!-- The core Firebase JS SDK is always required and must be listed first --&gt;
      &lt;!-- Add additional services that you want to use --&gt;
      &lt;script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-app.js"&gt;&lt;/script&gt;
      &lt;script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-auth.js"&gt;&lt;/script&gt;
      &lt;script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-database.js"&gt;&lt;/script&gt;
      &lt;script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-firestore.js"&gt;&lt;/script&gt;
      &lt;script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-messaging.js"&gt;&lt;/script&gt;
      &lt;script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-functions.js"&gt;&lt;/script&gt;
  
  
  
      &lt;!-- Firebase --&gt;
      &lt;script src="js/database.js"&gt;&lt;/script&gt;
  
  &lt;/head&gt;
  
      &lt;body&gt;
      &lt;div id="wrapper"&gt;
      &lt;nav class="navbar-default navbar-static-side" role="navigation"&gt;
      &lt;div class="sidebar-collapse"&gt;
      &lt;ul class="nav metismenu" id="side-menu"&gt;
  
      &lt;!-- User admining --&gt;
      &lt;li&gt;&lt;a href="dashboard_2.html"&gt;users&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>database.js, where I connect to firebase</p>
  
  <pre><code>var firebaseConfig = {
    apiKey: "AIzaSyBWVRTc7stMysJVw4rjvzzn5-FnvMAE8_8",
    authDomain: "proveneet.firebaseapp.com",
    databaseURL: "https://proveneet.firebaseio.com",
    projectId: "proveneet",
    storageBucket: "proveneet.appspot.com",
    messagingSenderId: "37090380224",
    appId: "1:37090380224:web:a9e4c49d1e4b80bf"
  };
    // Initialize Firebase
    firebase.initializeApp(firebaseConfig);
  
    var database = firebase.database();
  </code></pre>
  
  <p>dashboard_2.html</p>
  
  <pre><code> &lt;!--===============================================================================================--&gt;
          &lt;script src="https://www.gstatic.com/firebasejs/ui/3.6.1/firebase-ui-auth__es.js"&gt;&lt;/script&gt;
          &lt;link type="text/css" rel="stylesheet" href="https://www.gstatic.com/firebasejs/ui/3.6.1/firebase-ui-auth.css" /&gt;
          &lt;!-- The core Firebase JS SDK is always required and must be listed first --&gt;
          &lt;!-- Add additional services that you want to use --&gt;
          &lt;script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-app.js"&gt;&lt;/script&gt;
          &lt;script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-auth.js"&gt;&lt;/script&gt;
          &lt;script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-database.js"&gt;&lt;/script&gt;
          &lt;script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-firestore.js"&gt;&lt;/script&gt;
          &lt;script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-messaging.js"&gt;&lt;/script&gt;
          &lt;script src="https://www.gstatic.com/firebasejs/5.9.1/firebase-functions.js"&gt;&lt;/script&gt;
  
  
          &lt;!-- Firebase --&gt;
          &lt;script src="js/manageusers.js"&gt;&lt;/script&gt;
  
      &lt;/head&gt;
  
      &lt;body&gt;
              &lt;div id="wrapper"&gt;
              &lt;nav class="navbar-default navbar-static-side" role="navigation"&gt;
              &lt;div class="sidebar-collapse"&gt;
              &lt;ul class="nav metismenu" id="side-menu"&gt;
  
              &lt;li class="active"&gt;&lt;a href="dashboard_2.html"&gt;users&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  
  
  
  &lt;button class="btn btn-primary btn-lg float-right" type="submit" id="addusr"&gt;Next&lt;/button&gt;
  </code></pre>
  
  <p>manageusers.js, this is where i want to add info to the database</p>
  
  <pre><code>var connect = database.ref("/users");
  </code></pre>
  
  <p>If i copy what it is in database.js to manageusers.js and add var connect = database.ref("/users"); it tells me that the app already exists, if I don't it tells me that no firebase app was created, I want to use the same firebase database in both pages but I cannot do it this way, is there any way I can?</p>