Using reactjs, Get auth user info and add it to Firebase, before login redirect

I’m looking to create a function or an action in flows that does the following,

Before fully authentication, add user under that a specific collection (Firebase Firestore)

Get auth user info and add it to Firebase


Make a POST request with custom form values ?

const login = async () => {
try {

const user = await loginWithPopup()

// Add a new document with user info
await addDoc(collection(db, “cities”), user);


I’ve also tried to import firebase as a dependency in Actions to add it into login flow but I get an error

Const firebase = require(‘firebase’)