'Deleting a user with ReactJS/Firebase SDK
I'm trying to make an admin panel for my website which has a page to allow admins to delete users. The issue is, I have tried 2 different ways to delete a user using the Firebase SDK/React and I get similar errors for both methods.
Method 1 (where const app = firebase.initializeApp(...))
const auth = app.auth()
auth.deleteUser(uid)
Error:
_firebase__WEBPACK_IMPORTED_MODULE_1__.auth.deleteUser is not a function
Method 2
import { getAuth } from 'firebase/auth'
getAuth().deleteUser(uid)
Error:
_firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)(...).deleteUser is not a function
Solution 1:[1]
You can't delete a user by their UID from the client-side SDK, as that would allow any user of your app to delete any other user's account by simply knowing their UID (which is quite common).
The client-side SDK can only delete the currently signed-in user. To delete a user by their UID you will have to use the Admin SDK in a trusted environment (such as your dev machine, a server that you control, or Cloud Functions/Cloud Run).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Frank van Puffelen |
