Implement user Authentication in a Next.js app with Auth0

Xiaoru Li
InstructorXiaoru Li

Share this video with your friends

Send Tweet

With the Auth0 set up in our Next.js project, the next step is to integrate the authentication flow into our app.

In this lesson, we'll set up the API routes Auth0 needs to handle the auth process - /api/login, /api/logout and /api/callback. Then, we'll use the getServerSideProps lifecycle method in Next.js to authenticate users on the server-side. Finally, we'll update our /secret page component to have different states depending on the login session status of a visitor.

After this lesson, you will understand how to implement the user authentication logic in a Next.js app with Auth0.