You’re might — like me — already familiar with Firestore <=8, and you now want to try out the new features in v9. There have been made some clear changes, working with collections and documents.
When I saw the documents, how to migrate from 8 to 9:
https://firebase.google.com/docs/firestore/manage-data/add-data#set_a_document
I was still pretty confused. And for that reason, I will try to explain how I made it much more simple, with this small amount of codes.
Let’s start with the firebase config file
/app/firebase/firebase.js import { initializeApp } from "firebase/app";
import { getFirestore } from "firebase/firestore"; const firebaseConfig = {
apiKey: process.env.NEXT_PUBLIC_API_KEY,
authDomain: process.env.NEXT_PUBLIC_AUTH_DOMAIN,
databaseUrl: process.env.NEXT_PUBLIC_DATABASE_URL,
projectId: process.env.NEXT_PUBLIC_PROJECT_ID,
storageBucket: process.env.NEXT_PUBLIC_STORAGE_BUCKET,
messagingSenderId: process.env.NEXT_PUBLIC_MESSAGING_SENDER_ID,
appId: process.env.NEXT_PUBLIC_APP_ID,
measurementId: process.env.NEXT_PUBLIC_MEASUREMENT_ID
}; const app = initializeApp(firebaseConfig);
const db = getFirestore(app);