Reputation: 665
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
Upvotes: 2
Views: 7782
Reputation: 1
Firebase Authentication has a different import structure in version 9 To access the auth object, you should import it from 'firebase/auth' like this;
import { getAuth } from 'firebase/auth';
Upvotes: 0
Reputation: 317467
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.
Upvotes: 8