question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when using PhoneAuthProvider - Uncaught TypeError: app.auth is not a function

See original GitHub issue

[REQUIRED] Describe your environment

Operating System version: macOS Monterey 12.3.1 Browser version: Chrome Version 99.0.4844.84 (Official Build) (arm64) Firebase UI version: 6.0.1 FirebaseUI React Components: 6.0.0 Firebase SDK version: 9.6.10

[REQUIRED] Describe the problem

When using the PhoneAuthProvider the component loads but when you click on the “Sign in with phone number” button, the app crashes and you get the following error:

TypeError: app.auth is not a function
new RecaptchaVerifier
src/github.com/FinnUpstreet/src/recaptcha_verifier.ts:46
  43 | 
  44 |     // TODO: remove ts-ignore when moving types from auth-types to auth-compat
  45 |     // @ts-ignore
> 46 |     app.auth!()
     | ^  47 |   );
  48 |   this.type = this._delegate.type;
  49 | }
Uncaught TypeError: app.auth is not a function
    at new RecaptchaVerifier (static/js/vendors~main.chunk.js:12775:9)
    at push../node_modules/firebaseui/dist/esm.js.K.phoneSignInStart (static/js/vendors~main.chunk.js:187974:15)
    at L (static/js/vendors~main.chunk.js:184007:12)
    at static/js/vendors~main.chunk.js:188035:244
    at b (static/js/vendors~main.chunk.js:188022:11)
    at static/js/vendors~main.chunk.js:178588:18
    at xn.<anonymous> (static/js/vendors~main.chunk.js:184807:9)
    at ye (static/js/vendors~main.chunk.js:180542:24)
    at xe (static/js/vendors~main.chunk.js:180506:66)
    at dj (static/js/vendors~main.chunk.js:184252:11)
    at cj.push../node_modules/firebaseui/dist/esm.js.cj.h (static/js/vendors~main.chunk.js:184242:7)
    at ve (static/js/vendors~main.chunk.js:180403:16)
    at HTMLButtonElement.re (static/js/vendors~main.chunk.js:180454:14)
    at HTMLButtonElement.b (static/js/vendors~main.chunk.js:180350:18)

Steps to reproduce:

  1. Run app with StyledFirebaseAuth
  2. Attempt to sign in with phone number

Relevant Code:

import React from 'react'
import Firebase from 'firebase/compat/app';
import StyledFirebaseAuth from 'react-firebaseui/StyledFirebaseAuth';
import * as firebaseui from 'firebaseui';
import { getAuth } from 'firebase/auth'

const firebaseConfig = {
  apiKey: process.env.REACT_APP_FIREBASE_API_KEY,
  authDomain: process.env.REACT_APP_FIREBASE_AUTH_DOMAIN,
  databaseURL: process.env.REACT_APP_FIREBASE_DATABASE_URL,
  projectId: process.env.REACT_APP_FIREBASE_PROJECT_ID,
  storageBucket: process.env.REACT_APP_FIREBASE_STORAGE_BUCKET,
  messagingSenderId: process.env.REACT_APP_FIREBASE_MESSAGING_SENDER_ID,
  appId: process.env.REACT_APP_FIREBASE_APP_ID,
  measurementId: process.env.REACT_APP_FIREBASE_MEASUREMENT_ID,
};

// Initialize Firebase
const firebaseApp = Firebase.initializeApp(firebaseConfig);

export const auth = getAuth(firebaseApp);

export const uiConfig = {
  // Popup signin flow rather than redirect flow.
  signInFlow: 'popup',
  // Redirect to /signedIn after sign in is successful. Alternatively you can provide a callbacks.signInSuccess function.
  signInSuccessUrl: '/',
  // We will display Email and Phone as auth providers.
  signInOptions: [
    {
      provider: firebase.auth.PhoneAuthProvider.PROVIDER_ID,
      recaptchaParameters: {
        type: 'image', // 'audio'
        size: 'invisible', // 'invisible' or 'compact'
        badge: 'bottomRight' //' bottomright' or 'inline' applies to invisible.
      },
      defaultCountry: 'AU',
    }
  ],
};


export const SignUpPage = () => {
  return (
    <div>
        <StyledFirebaseAuth uiConfig={uiConfig} firebaseAuth={auth}/>
    </div>
  )
}

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:6

github_iconTop GitHub Comments

1reaction
m-elgamalcommented, Aug 16, 2022

Same issue here!!

0reactions
m-elgamalcommented, Sep 14, 2022

for some reason this issue was opened and closed by OP. may be he can help

Read more comments on GitHub >

github_iconTop Results From Across the Web

"TypeError: app.auth is not a function" when using ... - GitHub
Copied from #901 My project is React and when I run this code, I get this error TypeError: app.auth is not a function....
Read more >
firebase.auth is not a function - Stack Overflow
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 >
Firebase JavaScript SDK Release Notes - Google
Fixed a bug where @firebase/app-check-types was not included as a dependency of ... Fixed a bug that caused Uncaught TypeError: e.auth.
Read more >
FirebaseUI for Web — Auth - Firebase Open Source
FirebaseUI Auth provides a drop-in auth solution that handles the UI flows for signing in users with email addresses and passwords, phone numbers, ......
Read more >
this.ensureapp(...).auth is not a function - You.com - You.com
I'm adding authentication to a react app I'm working on with a basic signup page and firebase. I have a firebase.js, a Signup.js,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found