gladly-team / next-firebase-auth

Simple Firebase authentication for all Next.js rendering strategies

Home Page:https://nfa-example-git-v1x-gladly-team.vercel.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RFC: v1 roadmap

kmjennison opened this issue · comments

next-firebase-auth has been reasonably stable for a while now and is already used in production apps, so it feels an appropriate time to move toward a v1 release.

This is an in-progress document of the changes that might land in v1. Please comment with any feedback or questions.

The unstable releases are available as next-firebase-auth@canary. When contributing, please make pull requests to the v1.x branch.

Demo: the demo app is deployed here.


Prerequisites

Making the package work better

Making the package more flexible

  • #190
    Deferred: we'll delay this to a potential later release because 1) we won't want to complicate adoption of Firebase v9, 2) we haven't identified a suitable cookies library, and 3) this library might have a cookie-free future (see #287).
    • Identify a suitable cookies library
    • Identify a clear migration strategy for existing apps to avoid cookie mismatches
    • Implement
    • Write migration documents
  • #223
  • #233
  • #444

Preventing incorrect use

Developer tools

Cleanup

  • Make API name changes
    • Instances of AuthUser: AuthUser --> user
    • withAuthUser --> withUser
    • withAuthUserTokenSSR --> withUserTokenSSR
    • withAuthUserSSR --> withUserSSR
    • useAuthUser --> useUser
  • Review naming of exported types

Before release

  • #296
  • If needed, provide a codemod (jscodeshift)
  • Write migration guide
  • Ensure README is up to date

Hi, I'm picking up Firebase v9 support 👨‍💻

@kmjennison @HofmannZ Hi, any updates on the v1 release?

@atanaskanchev This is our checklist for a v1 release. I welcome contributions to speed things along. Meanwhile, v1 changes are available on the canary release channel.

We might defer a unified cookie feature (#190) to a later release because:

  1. we won't want to complicate adoption of Firebase v9
  2. we haven't identified a suitable cookies library, and
  3. this library might have a cookie-free future (see #287)

When will this library be available for next 12 version ?

@VewMet Next 12 is supported in the latest releases.

Firebase-admin 10.0.0 support should also be added to the roadmap

@Patrik-svobodik Firebase admin v10 is already supported.

Is Next.js' middleware functionality a place that next-firebase-auth could live? I assume it would be more performant? But does that make the hybrid server and client approach currently used almost impossible?

https://nextjs.org/docs/middleware

That could mean that pages lose auth/redirect on a page by page basis, instead be determined by file placement.

@seanaguinaga Thanks for flagging this. I opened an issue for middleware discussion here: #418

Hi guys, hope everything is going great. I am wondering if you have an estimated ETA for v1?

@DiegoGonzalezCruz We don't have an ETA—we're making progress as we have time. We welcome contributions on open issues. Meanwhile, next-firebase-auth@canary is available to use.

Hi,

it seems admin side is also modular:
import { initializeApp } from 'firebase-admin/app';

Currently we do:
import * as admin from 'firebase-admin'
admin.initializeApp()

@kmjennison is that safe to use next-firebase-auth@canary for a production app or the canary is for testing?

@raajnadar Yes, the canary releases are intended to be fully functional and usable in production. However, they'll be less stable and less tested than major releases, so you should only use it if you have tolerance for possible bugs or breaking changes.

The current canary version will see more breaking changes before it hits v1 stable. See release notes for these changes.

@kmjennison I am having a hard time upgrading to v17 - the admin config for initAuth is different?

have a complete example?

@seanaguinaga The config hasn't changed, but there are some breaking changes in v1.0.0-canary.17 (see release notes). Notably, we dropped support for firebase-admin v9 and removed the getFirebaseAdmin method. Instead, if you need the Firebase admin app, import it directly.

commented

@kmjennison I tried canary.17 and am receiving this error:

Error: The default Firebase app does not exist. Make sure you call initializeApp() before using any of the Firebase services.

canary.16 worked. With canary17, I removed the getFirebaseAdmin and replaced them with getFirestore() directly. I also ran initAuth() before these API route, even placed the initAuth right before the getFirestore() like this:

initAuth()
const firestore = getFirestore()

And the error still throw

commented

More context: I'm invoking these inside a getServerSideProps()

commented

Fixed it by wrapping the getServerSideProps inside the withAuthUser

EDIT: Apparently it worked locally, but when deploy it throws the error on the function...

I'm also having issues with the 'app/no-app' error code when trying to access the admin sdk on the server side. Both in API routes and getserversideprops. Strangely enough, it seems to work sometimes. I got it working suddenly, restarted the app, and then the errors came back..

If you're running into a bug, please try the example app with your own Firebase credentials (if you haven't already) to see if the bug exists there. Then, please open an issue with a minimal example app and instructions to reproduce.

v1 beta is out! 🎉 Check out the migration guide and let me know if you run into any issues.

v1.0.0 has been released!