I recently integrated the new version of next-auth, which is V5. The installation took longer than I expected due to the lack of documentation. Since next-auth is becoming part of auth.js, original website does contain more detailed documentation for previous versions, but the new version documentation is still in progress to be migrated to the new website. Let’s dive into all the steps I took to set it up and also explore how to use session information and auth functions both in server and client components!
First, you need a Next.js project to work with. If you don’t have one yet, you can create it using the create-next-app
command in your terminal. This command will set up a new project with all the necessary files and dependencies for a Next.js application.