title: Error when creating or overwriting a document in firebase
body: <p>I am trying to add user or overwrite the user document in case the user already exists but I am getting this error:</p>
  <blockquote>
  <p>FirebaseError: Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore</p>
  </blockquote>
  <p>What am I doing wrong?</p>
  <pre><code>import { auth, db }  from &quot;../firebase&quot;
  import {doc, setDoc} from 'firebase/firestore'
  import { useEffect } from &quot;react&quot;;
  
  
  unction MyApp({ Component, pageProps }) {
  
    useEffect(() =&gt; {
      if(user){
        setDoc(doc(db, 'users', user?.uid), {
          email : user.email,
          lastSeen: firebase.firestore.FieldValue.serverTimestamp(),
          photoURL : user.photoURL
        }, {merge: true});
      }
    }, [user])
  }
  
  export default MyApp
  </code></pre>