Skip to content

RFC: discuss value of Next.js middleware #418

@kmjennison

Description

@kmjennison

Next.js supports middleware, which this library could recommend as a way to integrate with next-firebase-auth. I'd like to gather input on whether middleware provides value that the current API (withAuthUser and withAuthUserTokenSSR) does not.

My initial assessment is that middleware usage could be a good option for apps where auth info is needed on many or all pages and the server-side auth/redirect settings don't change between pages. In this scenario, middleware could provide an AuthUser on the request object in getServerSideProps or redirect as needed.

However:

  • Middleware can't currently set return data or set React context; thus, unlike the existing API for SSR pages, AuthUser won't be set on the client side until the Firebase JS SDK initializes.
  • Middleware reduces flexibility on whether to use auth info on individual pages.

Feedback and input appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCRequest for comments and ideasenhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions