I am currently working on implementing email and password authentication using Firebase Auth with Next.js. This time, I want to utilize a dedicated UID for authentication purposes. In order to achieve this, I believe it would be better to use the createUser
method instead of createUserWithEmailAndPassword
. However, I'm encountering an error message:
Property 'createUser' does not exist on type 'Auth'.
import { getAuth, createUserWithEmailAndPassword } from 'firebase/auth'
const auth = getAuth()
const newId = XXXXXXXXXXXXXx
getAuth()
.createUser({
uid: newId,
email: data.email,
password: data.password,
})
.then((userRecord) => {
// See the UserRecord reference doc for the contents of userRecord.
console.log('Successfully created new user:', userRecord.uid);
})
.catch((error) => {
console.log('Error creating new user:', error);
});
// It works
createUserWithEmailAndPassword(auth, data.email, data.password)