That being said, I want to have the perks of authentication without a user going through sign up / sign in methods. I'm developing an app with notes' interacting (read, write, delete) and I need to connect the data to a specific user. USER A can't access notes of USER B and vice versa. So I'm wondering whether there's a solution for pure React + Firebase or not.
Asked
Active
Viewed 289 times
1 Answers
1
What you're looking for is Firebase's anonymous authentication. This signs the user into Firebase, without requiring them to enter credentials.
If needed you can later allow the user to sign-in with a supported provider, and link that to their existing (anonymous) account.

Frank van Puffelen
- 565,676
- 79
- 828
- 807
-
Yes I've actually encountered this solution but isn't this kind of authentication temporary which means I'll lose it after a while? – h1kiga Feb 17 '21 at 15:38
-
Nope. Anonymous authentication lasts until the user explicitly signs out, or uninstall the app. See https://stackoverflow.com/questions/47854428/how-constant-is-the-firebase-anonymous-id – Frank van Puffelen Feb 17 '21 at 15:41
-
Below the same thread you've sent I've read that it won't survive cleaning cache, so there's no confidence it'll be available forever. Anyway, I'm not up to a global project so this functionality will be more than enough. Thank you for your help! – h1kiga Feb 17 '21 at 15:58
-
Can you link me to the precise place where you read that about the UID surviving a cleaning of a cache? – Frank van Puffelen Feb 17 '21 at 17:22
-
**android:** https://stackoverflow.com/questions/54441341/does-firebase-anonymous-authentication-survive-when-clearing-app-cache#:~:text=To%20directly%20answer%20the%20question,you%20clear%20the%20app%20data. **web:** [These anonymous sessions can be configured to last days, weeks, months, even years… until the user logs in with a permanent login method or clears her browser cache.](https://howtofirebase.com/firebase-authentication-for-web-d58aad62cf6d#c153) – h1kiga Feb 17 '21 at 20:32
-
Ah yes, when you clear app data, that indeed clears the UID too. We hardly ever see this causing problems though. But if you foresee problems with it for your app, you'll have to come up with a mechanism that persists across such data clean up - yet still doesn't require the user to sign in with credentials. If you do that, you could consider implementing it as a custom auth provider in Firebase too. – Frank van Puffelen Feb 17 '21 at 21:56