Feature Request: Offer Auth Provider
See original GitHub issueIs your feature request related to a problem? Please describe.
I’m looking at adding next-firebase-auth
to a site I’m working on, but it has a persistent nav which shows the login status.
Unless I’m missing something, I would have to wrap every single page with the withAuthUser()
HOC, as well as call the useAuthUser
function in each of those pages. I would also need to move my Layout
component out of my _app
and into every page, meaning even more duplication on every page.
Describe the solution you’d like and how you’d implement it
A React Context Provider could be exposed so that developer can wrap their _app
component with this allowing them to call the useAuthUser
hook from any nested component.
Is this a breaking change? I’m not sure if this would be a breaking change, I’m pretty sure this could be achieved without breaking the useAuthUser() API, but I haven’t tried so I’m not sure.
Describe alternatives you’ve considered
Since this functionality does appear to exist, the only way I can think to achieve this is to not use next-firebase-auth
at all, and instead write the functionality myself.
Thanks for your consideration.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:6 (3 by maintainers)
Top GitHub Comments
I am pretty much in the same boat. I have a component called Layout that is loaded in
_app.js
. The layout component has the following navigation buttons:I was able to get it working by wrapping the Layout component like this:
I still think a provider might be a good thing to offer as some people might need it (but discourage people from using it in the README).
Until Next has support from running
getStaticProps
etc in_app
, or an alternative for statically rendering external data sources, I think people are going to want to at least have the option to use global data, as you can easily end up with quite a lot of boilerplate code that you will otherwise need to add to every page.Having said that, I’ve done a bit of thinking and I agree with you @tlays — it’s not worth loading up Firebase on every page. I’m going to refactor how my nav works instead.
Thanks so much for your suggestions and detailed responses, I really appreciate it 😊