0

I was using useAuthState() hook for the authentication from 'react-firebase-hooks/auth'. I was curious to know how is it working. Is it storing cookies and clearing it once logged out or is it requesting the firebase everytime ? if this is the case how does it get the reference that a particular person is logged in i mean what parameter(like uid, email) is it passing in the request and how is it getting it.

https://i.stack.imgur.com/XiCQp.jpg

This image is the network part it is requesting with uid but where is it storing??

imjared
  • 19,492
  • 4
  • 49
  • 72
Suraksh NS
  • 3
  • 1
  • 3

1 Answers1

3

useAuthState() hook from 'react-firebase-hooks' is a wrapper around firebase's onAuthStateChanged() function, as you can see here: https://github.com/CSFrequency/react-firebase-hooks/blob/master/auth/useAuthState.ts

onAuthStateChanged() (among other things) sets an observer (callback) on Auth object. Auth object itself calls home to firebase to verify signed in user with an access token (if available) which is stored in browser. Read more about it here: https://firebase.google.com/docs/auth/web/manage-users

Firebase does not store this token in cookies, but in indexedDB, you can see it here:

IndexedDB storage

Read more about IndexedDB: https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API

You can go to Application > Storage > Clear site data (depending on your dev. tools). This will clear site's indexedDB and log user out.