2
1 Comment

Seeking Advice: Implementing Anonymous User Sessions - Firebase Anonymous Account or Local IndexedDB?

Hello fellow developers! ๐Ÿ‘‹

I am currently engrossed in the development of a new feature for my app, Typogram, that aims to support anonymous user sessions of the app. Iโ€™m at a crossroads and could use some wisdom.

Quick background:

  • For authentication and data storage, I use Firebase.
  • Upon account creation, user data automatically finds its home in Firestore.
  • I've also implemented local IndexedDB storage which is for offline usage and the storage of bulky data chunks like undo/redo history that are not cloud-bound.

So, here lies the fork in the road: Should I implement anonymous user sessions using Firebase anonymous accounts or should I lean on the local IndexedDB?

๐Ÿ”ฅ Firebase Anonymous Accounts

  • Operates much like a full-fledged account except no user information.
  • User data would be stored in Firestore as usual, that comes with its own set of fees.
  • ChatGPT says the Firebase anonymous session close when browser closes, which is not ideal.

๐Ÿ–ฅ Local IndexedDB

  • This route is financially free, storing user data locally in the userโ€™s browser.
  • I already laid the groundwork prior, so development time is shorter.
  • The data is persistent even when browser is closed and reopened

Firebase tips the scale when it comes to data insights, offering a clearer perspective on the number of anonymous users and allowing for a nuanced tracking of their behaviors. But, itโ€™s important to mention that to harness this, a decent investment of development time is necessary.

Iโ€™m eager to hear your valuable opinions, experiences, or insights on choosing the most effective path. Your input will be immensely helpful in navigating this decision!

Thank you in advance! ๐Ÿ™

on October 26, 2023
  1. 1

    I would like to provide you with some insights that might help you make better decisions.

    If I were to make something anonymous, I would opt for local storage, such as IndexedDB. It can handle a substantial amount of data locally, and you can also sync it to the cloud or your own server if you ever wish to collect some statistical data.

    This is based on my personal preferences since I already have experience building a similar system with IndexedDB, and I lack experience with Firebase. Firebase might offer advantages that I may have overlooked. It also depends on the nature of your app.

    For instance, if you only need simple session handling to persistently identify users uniquely so they can participate in discussions with their own unique usernames, you can do so without any issues with IndexedDB or localStorage. I recently launched an anonymous discussion platform using localStorage to store the users' uid, which is called Tailgram (coincidentally, it sounds somewhat similar to Typogram :)).

    This approach also has its disadvantages: the stored data can be deleted from users' browsers or when users switch to different browsers, but the impact is not that significant.