I am working on a nextjs project, for user authentications I am using firebase’s signInWithPhoneNumber for phone number verification, after successfull verification I get a firebase user which also has the getIdToken method to fetch a new token. My problem is after I refresh the page I cannot use this method to fetch a token as the currentUser user becomes undefined after page reload.
Mainly I want to use the getIdToken method of firebase user even after page reload. But I am in such a scenario where page reload is inevitable.
I tried storing the firebase user in localstorage but user is saved as a string and even after parsing it is an object which does not have the getIdToken method. So I cannot use it.