gladly-team / next-firebase-auth

Simple Firebase authentication for all Next.js rendering strategies
https://nfa-example-git-v1x-gladly-team.vercel.app/
MIT License
1.35k stars 290 forks source link

Explore using service workers to manage sessions #287

Open kmjennison opened 3 years ago

kmjennison commented 3 years ago

I'd like to explore using service workers to manage Firebase sessions. This would be a big shift in how this package works, so input is very much welcome!

See Firebase docs: Session management with service workers

Firebase Auth provides the ability to use service workers to detect and pass Firebase ID tokens for session management. This provides the following benefits:

  • Ability to pass an ID token on every HTTP request from the server without any additional work.
  • Ability to refresh the ID token without any additional round trip or latencies.
  • Backend and frontend synchronized sessions. Applications that need to access Firebase services such as Realtime Database, Firestore, etc and some external server side resource (SQL database, etc) can use this solution. In addition, the same session can also be accessed from the service worker, web worker or shared worker.
  • Eliminates the need to include Firebase Auth source code on each page (reduces latency). The service worker, loaded and initialized once, would handle session management for all clients in the background.

This Firebase feature is still in beta as of 2021.08.26.

Additional benefits:

Downsides:

Work

kmjennison commented 1 year ago

Some early work on this here: #680