-
Notifications
You must be signed in to change notification settings - Fork 287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Offer Auth Provider #64
Comments
Hi @lukebennett88, it's an interesting request, and a good idea. In one of my projects I had actually built this feature myself base on this example which I had enhanced to lazy-load some components. However in the end, I scrapped all my code and came back to The biggest problem with nextJs and adding an Now if the app has a persistent login status in a permanent navbar (like yours), it's less of a problem, obviously. But for other sites/apps that don't want to extra bytes loaded on every page, it's a pain. Now I'm not saying that |
@lukebennett88 Thanks for the feature request. If you're okay with using the Firebase user loaded only on the client side, you can wrap a component in If you're hoping to include the Firebase user in Off the top of my head, here's another somewhat hacky approach you could take: in |
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 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 😊 |
I am pretty much in the same boat. I have a component called Layout that is loaded in
I was able to get it working by wrapping the Layout component like this:
|
I'm going to close this and aim to have this package follow Next.js's features/recommendations for data fetching. Right now, Next doesn't support |
I found this discussion after seeing a similar issue that @lukebennett88 mentioned with having to copy layouts between components and then add withAuthUser to each default export. My solution was to have a LayoutWithNav component that gets set like this:
LayoutWithNav looks like this:
This solved my issues so that I can use the useAuthUser() hook anywhere I add that LayoutWithNav to a page. Sharing here in case someone else comes across this issue and could use a concrete example. |
Is 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 theuseAuthUser
function in each of those pages. I would also need to move myLayout
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 theuseAuthUser
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.
The text was updated successfully, but these errors were encountered: