question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature Request: Offer Auth Provider

See original GitHub issue

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 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:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
samos123commented, Feb 10, 2021

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:

        {AuthUser ? (
          <Button variant="primary" onClick={AuthUser.signOut}>
            Logout
          </Button>
        ) : (
          <SigninButton/>
        )}

I was able to get it working by wrapping the Layout component like this:

export default withAuthUser()(Layout)
2reactions
lukebennett88commented, Feb 10, 2021

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 😊

Read more comments on GitHub >

github_iconTop Results From Across the Web

Authentication Provider Best Practices: Universal Login - Auth0
Learn why universal login is the most secure, standards-based strategy when authenticating with a provider.
Read more >
Authentication Providers - Salesforce Help
Salesforce offers predefined authentication providers for several third parties, ... Salesforce uses the access token to request information about the user.
Read more >
Feature Request: SAML based authentication #6600 - GitHub
SAML is based on third part identity provider and you can find a lot of them. Office 365 and Azure AD can be...
Read more >
Feature requests - Passbase
In Review• Feature Request• 0 ... When a user is redirected to mobile, Passbase offers 3 choices to ... It can be similar...
Read more >
Authentication and authorization - Azure App Service
Feature architecture · Authenticates users and clients with the specified identity provider(s) · Validates, stores, and refreshes OAuth tokens ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found