Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to implement firebase in the next.js file
but i keep getting the error module not found
(i already use yarn add firebase)

What I have tried:

file where i want to implement firebase


import { useSession } from 'next-auth/client';
import { EmojiHappyIcon } from "@heroicons/react/outline";
import { CameraIcon,VideoCameraIcon } from "@heroicons/react/solid";
import{  useRef } from "react";
import { db } from "../../firebase";
import firebase from "../../firebase";
function InputBox() {
    const [session]=useSession();
    const inputRef=useRef(null);

    const sendPost = (e) => {
      e.preventDefault();


    if(!inputRef.current.value) return;

    db.collection('posts').add({
        message: inputRef.current.value,
        name: session.user.name,
        email: session.user.email,
        image: session.user.image,
        timestamp: firebase.firestore.FieldValue.serverTimestamp()
      })

      inputRef.current.value="";
    };


firebase file
import firebase from "./firebase";
import "firebase/storage";
const app = !firebase.apps.length ? firebase.initializeApp(firebaseConfig) : firebase.app() ;
const db = app.firestore();
const storage= firebase.storage();

export { db, storage }; 
Posted
Updated 4-Nov-21 22:47pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900