title: Firebase Realtime Database - "Error: Client is offline". React/NextJS
body: <p>Using React with NextJS the following error occurs occasionally when fetching data from a Firebase Realtime Database.</p>
  <pre><code>Unhandled Runtime Error
  Error: Error: Client is offline.
  </code></pre>
  <p>I am using Firebase <code>9.0.1</code> for React.</p>
  <p>Top Level code for intialisation and config</p>
  <pre><code>import { initializeApp } from &quot;firebase/app&quot;;
  import { getDatabase, ref, onValue, child, get } from &quot;firebase/database&quot;;
  import CONFIG from '../CONFIG.json'
  
  
  const FIREBASE_CONFIG = {
    apiKey: CONFIG['FIREBASE_API_KEY'],
    authDomain: CONFIG['FIREBASE_AUTH_DOMAIN'],
    databaseURL: CONFIG['FIREBASE_DATABASE_URL'],
    storageBucket: CONFIG['FIREBASE_STORAGE_BUCKET']
  
  }
  const fbApp = initializeApp(FIREBASE_CONFIG)
  </code></pre>
  <p>And later fetching data</p>
  <pre><code>export default function Leads() {
    ...
  
    useEffect(() =&gt; {
      const database = getDatabase(fbApp)
      const ads = ref(database, 'ad_results')
  
      get(ads).then((snap) =&gt; {
        const results = snap.val()
        ...
  </code></pre>
  <p>I have tried searching similar issues but to no avail, any help would be appreciated.</p>