"TypeError: app.auth is not a function" when using PhoneAuthProvider
See original GitHub issueimport {useEffect} from "react";
import {initializeApp} from "firebase/app";
import {getAuth, PhoneAuthProvider} from "firebase/auth";
import * as firebaseui from 'firebaseui'
import 'firebaseui/dist/firebaseui.css'
function App() {
const firebaseConfig = {
...
};
const app = initializeApp(firebaseConfig);
const uiConfig = {
signInSuccessUrl: '<url-to-redirect-to-on-success>',
signInOptions: [
PhoneAuthProvider.PROVIDER_ID
],
tosUrl: () => alert('Terms of service'),
privacyPolicyUrl: () => alert('Privacy policy')
};
// SOURCE: https://github.com/firebase/firebaseui-web/issues/216#issuecomment-459302414
const ui = firebaseui.auth.AuthUI.getInstance() || new firebaseui.auth.AuthUI(getAuth());
useEffect(() => {
ui.start('#firebaseui-auth-container', uiConfig);
}, []);
return (
<div className="App">
<div id="firebaseui-auth-container"/>
</div>
);
}
export default App;
My project is React and when I run this code, I get this error TypeError: app.auth is not a function.
This only happens when I use PhoneAuthProvider.PROVIDER_ID
, when I insert GoogleAuthProvider.PROVIDER_ID
everything works fine.
I tried with multiple devices and environments and I always get the same error.
Does my code have any mistakes?
Thanks in advance.
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
app.auth is not a function" when using PhoneAuthProvider ...
This only happens when I use PhoneAuthProvider.PROVIDER_ID, when I insert GoogleAuthProvider.PROVIDER_ID everything works fine. firebase no ...
Read more >firebase.auth is not a function
As suggested in web get started guide. However, when I try to use firebase.auth() I get an error: console.js:32 TypeError: firebase.
Read more >PhoneAuthProvider | Firebase JavaScript API reference
Reference for PhoneAuthProvider. ... at Firebase Summit, and learn how Firebase can help you accelerate app development and run your app with confidence....
Read more >FirebaseUI for Web — Auth
Use the same OAuth client ID used for the Google provider // configured with GCIP or Firebase Auth. clientId: 'xxxxxxxxxxxxxxxxx.apps.googleusercontent.com' }, ...
Read more >FirebaseRecaptcha
Firebase phone authentication is not possible out of the box using the Firebase JS ... getApp } from 'firebase/app'; import { getAuth, PhoneAuthProvider, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@wonsuc I think that would be one of the top priorities.
can you try
using compat library would change the import style see here