Encountering an issue with undefined this.auth.settings when implementing Firebase Phone Authentication in NextJS 14

I am facing an issue with authenticating users using the firebase OTP system.

Can someone assist me with resolving the problem of 'this.auth.settings is undefined' while implementing Firebase Phone Authentication in NextJS 14?

The code snippet from app/login/page.js:

'use client'
import { useState, useRef } from 'react';
import Link from 'next/link';
import { useRouter } from 'next/navigation'
import { BiArrowBack } from 'react-icons/bi';
import PhoneInput from 'react-phone-input-2'
import 'react-phone-input-2/lib/style.css'
import styles from './Login.module.css';
import OTPInput from 'otp-input-react';
import { CgSpinner } from "react-icons/cg";
import { auth } from "../firebase";
import toast, { Toaster } from 'react-hot-toast';
import { RecaptchaVerifier, signInWithPhoneNumber } from "firebase/auth";
import { BsFillShieldLockFill, BsTelephoneFill } from "react-icons/bs";

export default function Login() {
    // rest of the component's logic here

In my firebase.js file, I have hidden sensitive information:

// Import necessary functions from the required SDKs
import { initializeApp } from "firebase/app";
import { getAuth } from "firebase/auth";

// Your web app's Firebase configuration
// Configuration details go here

// Initialize Firebase
const app = initializeApp(firebaseConfig);

export const auth = getAuth(app);

After clicking the continue button, the onSignup function is triggered but I encounter the following error:

https://i.sstatic.net/CEDIw.png

Your assistance would be greatly appreciated. Thank you!

Answer №1

In order to successfully authenticate, make sure to place the auth argument as the first one:

 window.recaptchaVerifier = new RecaptchaVerifier(
        auth,
        "recaptcha-container"
        {
          size: "invisible",
          callback: (response) => {
            onSignup();
          },
          "expired-callback": () => {},
        },
      );

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Response from Socket.io: What is the best way for the server to respond to all clients after receiving input from multiple clients?

Currently diving into the realm of node.js, express, and socket.io Thrilled to report that my server is up and running, successfully connecting to the browser via localhost:3000 Communication between client and server is seamless both ways. Now, onto th ...

Encountering an Issue: The program is throwing a TypeError because it is unable to access properties of null when trying to read '

My goal is to upload an excel file using ng-click and the fileUpload($event) function defined in the app controller scope. I am utilizing xlsx to read the file in JSON format, but I encounter an error when running the code: <div> <input id ...

What might be causing the issue in the build process of my next.js project?

**Why is my Node.js YAML file causing an error?** name: Node.js CI on: push: branches: [ "main" ] pull_request: branches: [ "main" ] jobs: build: runs-on: ubuntu-latest strategy: matrix: node-ver ...

Next.js server-side rendering encountered an issue with hydration

I'm currently facing issues while using the react-i18next dependency with next.js. Within my _app.js file, I have the following code snippet: if (!isServer) { init_i18n(); } function MyApp({ Component, pageProps }) { // The presence of this ...

Exploring JqueryUI tab navigation with the help of the <a> tag

I have come across several articles mentioning the possibility of navigating JqueryUI tabs using a button or anchor tag. Here is the method I am currently using: $("#vtabs").tabs(); $("#tabsinner").tabs(); $(".changeTab").click(function() { alert("as ...

What is the best way to format a date input field so that when a user enters a year (yyyy), a hyphen (-

Need help with date formatting in the format yyyy-mm-dd. Seeking a way to prompt user input for the year and automatically append "-" to the date as needed. Also utilizing a datepicker tool for selecting dates. ...

Connecting events to maps in AngularUI

Currently, I am working with AngularJS and the AngularJS UI modules to integrate Google Maps into my application and perform various actions on its events. One issue I have encountered is that the ui-events call function is not passing any parameters or da ...

Incorporate information into a React component

I'm currently working on my initial react component and facing a challenge while adding items to the parent element through an external click event. The user needs to select from a list of search results, and I intend for these selections to be incorp ...

What issues can arise in JavaScript if the URL length is not zero when there is no match found?

Upon clicking the "Open Windows" button in Code A, I expected the two links to open in two tabs simultaneously in Chrome, which is exactly what happened. However, when I added a blank line in the textarea control in Code B, only the link http:// ...

Is it possible to automatically adjust the size of components on a html/cshtml page based on the current window size?

Currently, I am facing an issue with my website where multiple panels are created using a foreach loop that includes textareas/textboxes. Whenever I resize my browser window, it messes up the UI by shifting the position of the textareas and other elements. ...

Ways to tidy HTML/XML code?

Upon receiving a web service response, the data appears as such: <text>&lt;span class="TitleServiceChange" &gt;Service Change&lt;/span&gt; &lt;span class="DateStyle"&gt; &amp;nbsp;Poste ...

The DIV element with a line break tag displaying text on a new line

In my project, I am working with an XMLHTTPResponse object that contains nodes. My goal is to print the elements of one specific node (serps) in a div element, but in a formatted manner. The structure of the node is as follows: Currently, I need to create ...

Issue with image magnification on Internet Explorer 9 using the Cloud Zoom plugin extension for Joomla

Recently, I've been utilizing a Joomla plugin called cloud zoom to enhance our gallery by providing an image magnification effect when hovering over the large image. You can see it in action on this link here. While it works flawlessly on most browser ...

The data from the Subscribe API call is gradually loading within the ngOnInit() function

When using Angular 8, I am experiencing slow data retrieval when making API calls in the ngOnInit() function. The issue arises when trying to pass this data as @Input from one component module to another - it initially comes through as undefined for a minu ...

Absence of property persists despite the use of null coalescing and optional chaining

Having some trouble with a piece of code that utilizes optional chaining and null coalescing. Despite this, I am confused as to why it is still flagging an error about the property not existing. See image below for more details: The error message display ...

What is the method for sending an array in x-www-form-urlencoded format using react-native?

this function is used for sending the API request export const socialPostMurmur= (publicKey,content,sig,visibility,video,photo)=>{ // console.log(publicKey,content,sig,visibility,video,photo); console.log('photo',photo); let data; da ...

What steps should I take to address the issues with my quiz project?

I've been working on a new project that involves creating a quiz game. I came across some code online and decided to customize it for my needs. However, I'm encountering some issues with the functionality of the game. Right now, the questions ar ...

Unable to call an object that may be 'undefined': Utilizing a function with a return object that includes asynchronous functions as properties

I have a function exported in my adapter.ts file: import type { Adapter } from "@lib/core/adapters"; export default function MyAdapter (): Adapter { return { async createUser (user: User) { ... }, async findUserByEmail (email ...

Is there a way to automatically dismiss a notify.js notification?

I am currently attempting to forcefully close an opened notification by clicking a button, following the instructions provided in the advanced example of the notify.js API. Can someone please explain how this can be accomplished? function CLOSE() { $( ...

Dealing with 404 errors encountered when making requests to external websites, utilizing either basic Javascript or JQuery

I have links in my application that redirect to external websites. For example, a link might look like this: <http://www.google.com'>>General Search<>. Users input the href and we dynamically create the link without any validation of it ...