title: NextJS: Accessing Google Firestore data
body: <p>So I'm not sure how to do this exactly. Here is what I have:</p>
  
  <p>In my <code>Index.js</code> I have</p>
  
  <pre><code>Index.getInitialProps = async function () {
    const firebase = require('firebase')
  
    const firebaseConfig = {
      apiKey: "examplezbxW_9nKoUjas",
      authDomain: "example-prod.firebaseapp.com",
      databaseURL: "https://example-prod.firebaseio.com",
      projectId: "example-prod",
      storageBucket: "example-prod.appspot.com",
      messagingSenderId: "1234567890",
      appId: "1:1234567890:web:1234567890"
    };
  
    if (!firebase.apps.length) {
      firebase.initializeApp(firebaseConfig)
    }
  
    const db = firebase.firestore()
  
    const data = db.collection('data').get()
  
    return {
      data
    }
  }
  </code></pre>
  
  <p>This gives me an error of <code>FirebaseError: projectId must be a string in FirebaseApp.options</code></p>
  
  <p>(Maybe I need to run the firebase node package and login...)</p>
  
  <p>It says the error is occurring at this line <code>const db = firebase.firestore()</code></p>
  
  <p>Any help is appreciated. Maybe this isn't the spot I should be trying to load firestore data... not sure.</p>
  
  <p>I also considered creating a node server and doing it that way, but ideally, I'd like to avoid that.</p>