auth' is not exported from 'firebase' in react app

Viewed 5924

This is my first time using firebase in react and I get the error in a userProvider.js file

auth' is not exported from 'firebase'

while in my firebase.js I do

 import "firebase/auth";
 export const auth = firebase.auth();

and in my userProvider.js file I import it as

import {auth} from 'firebase';

I'm a complete beginner in this . I don't know if I'm missing something easy here

1 Answers

You're not importing the Firebase SDKs correctly. Be sure to read the documentation on using Firebase with module bundlers. Starting with v8.0.0, you have to import Firebase SDKs like this:

import firebase from "firebase/app"
import "firebase/auth"

const auth = firebase.auth()

Do not import from "firebase" directly.

Related