Skip to content
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

Closed
lunchboxav opened this issue Sep 3, 2020 · 6 comments
Closed

Should I use this, or auth0-react? #163

lunchboxav opened this issue Sep 3, 2020 · 6 comments

Comments

@lunchboxav
Copy link

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 :)

@jonathanredford
Copy link

jonathanredford commented Sep 3, 2020

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:
serverless-server-api-call

@mosesoak
Copy link

mosesoak commented Sep 3, 2020

@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)

@jordie23
Copy link

the fact that this is currently on ice as they upgrade their ecosystem of libs internally

Sorry a little OT, but is there more information about this somewhere?

@aorsten
Copy link

aorsten commented Dec 26, 2020

@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? 😊

@Widcket
Copy link
Contributor

Widcket commented Jan 15, 2021

Hi everyone, we have included the answer to this question in the README of the new beta version. Please check it out here.

@Widcket Widcket closed this as completed Jan 15, 2021
@andremarcondesteixeira
Copy link

andremarcondesteixeira commented Feb 10, 2023

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants