-
Notifications
You must be signed in to change notification settings - Fork 397
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
Should I use this, or auth0-react? #163
Comments
From my understanding, the reason this package (nextjs-auth0) exists is to allow you know whether the user is authenticated when rendering the page on the server, which saves the client having to initially load the page and then make an API call with the session cookie. This diagram (pulled from Auth0's guide) explains further what is happening with the nextjs-auth0 package: |
@lunchboxav You should read this article carefully: https://auth0.com/blog/ultimate-guide-nextjs-authentication-auth0/ It's the mother lode. You should absolutely use this library with next.js! -- it fully enables server-side auth using a cookie-based system. The react one is purely frontend. FYI the only true limitation of this library we've found after using it is that if you update user metadata on Auth0 it will not be synced back to the cookie, so it's difficult to implement user-pref features with it. In contrast their 2 frontend-facing libs (js, react) are set up to do silent re-authentication which pulls down the latest user prefs. Other than that, and the fact that this is currently on ice as they upgrade their ecosystem of libs internally, this library is a very powerful approach. Even though SSG pages won't be able to use server-side auth, it's easy enough to call an api route that loads the logged-in user just after first render which is usually just a split second since it's cached, see my example here: #132 (comment) |
Sorry a little OT, but is there more information about this somewhere? |
@mosesoak Ref the above post, do you have any more info regarding auth0's upgrade of their lib ecosystem? Or a link to some info? 😊 |
Hi everyone, we have included the answer to this question in the README of the new beta version. Please check it out here. |
@Widcket the link you posted is broken. There is nothing in the documentation mentioning how to use this lib to call an external api from the frontend |
I'm starting a new project which requires me to implement authentication for both accessing page and API. I'm developing it using Next.js. So, my question is, should I use this library or the auth0-react? I've given both a quick PoC and they seem to be working at least for what I was aiming at.
Is there any advantage that one gives over the other?
Thank you :)
The text was updated successfully, but these errors were encountered: