title: Problem with getAuth() in a different route - SvelteKit
body: <p>I am trying to set up Firebase email/password authentication in SvelteKit. In <code>__layout.svelte</code> I initialize my Firebase app:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;script lang=&quot;ts&quot;&gt;
      import { onMount } from 'svelte';
      import { initializeApp } from 'firebase/app';
  
      onMount(() =&gt; {
          // Your web app's Firebase configuration
          const firebaseConfig = {
              apiKey: '***',
              authDomain: '***.firebaseapp.com',
              projectId: '***',
              storageBucket: '***.appspot.com',
              messagingSenderId: '***',
              appId: '***'
          };
  
          // Initialize Firebase
          const app = initializeApp(firebaseConfig);
      });
  &lt;/script&gt;
  </code></pre>
  <p>For my login/signup route, I need to call <code>getAuth()</code> but whenever I do, I get an error:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;script lang=&quot;ts&quot;&gt;
      import { onMount } from 'svelte';
      import { getAuth, connectAuthEmulator } from 'firebase/auth';
  
      onMount(() =&gt; {
          const auth = getAuth(); //**ERROR HERE**
          connectAuthEmulator(auth, 'http://localhost:9099');
      });
  &lt;/script&gt;
  </code></pre>
  <p>The error I get is:</p>
  <blockquote>
  <p>Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp()</p>
  </blockquote>
  <p>I think this is because I need to pass the <code>app</code> from <code>__layout.svelte</code> inside the <code>getAuth()</code> function, but I don't know how to export <code>app</code> to my login route to do so.</p>