import { doc, setDoc } from "firebase/firestore";
// Add a new document in collection "cities"
await setDoc(doc(db, "cities", "LA"), {
name: "Los Angeles",
state: "CA",
country: "USA"
});
Adding new document with auto generated id
//imports
import { db } from "../../config/firebase.config";
import { collection, addDoc } from "firebase/firestore";
//code inside component
const addData = async () => {
collectionRef = collection(db, "collectionName")
payload = { whatever your payload is }
await addDoc(collectionRef, payload)
}