Recently, I delved into the world of Next.js and Firebase. However, my attempt to connect a Realtime Database to my Next.js project proved unsuccessful. Here are the steps I took:
- Created a Next.js app
- Set up a Firebase project
- Added a web app to the Firebase project and ran "npm install firebase" in the Next.js app directory
- Copied and pasted the SDK into a firebaseConfig.js file within the app folder of the Next.js project
- Configured the Realtime Database with test mode settings
- Included the databaseURL in the firebaseConfig.js file
- Attempted to push data to Firebase using the following code snippet
const usersRef = ref(database, 'users');
const newDataRef = push(usersRef);
set(newDataRef, {
user: props.email,
password: props.password
});
Upon checking the console, no errors were reported.