Next-Auth in App Router of Next.js
5 min readJun 27, 2023
If you are not memeber of the medium.com, read here for free
Next.js has recently released a stable version of App Router enriched with in-built support for layouts, templates, routing, loading, and error handling.
The current version of Next-Auth documentation is published with examples of the Page Router of Next.js. This document share approach to setting up Next.js with the Next-Auth App Router.
What is covered in this document?
- Setup of Next.js app with app router.
- Install Next-Auth.
- Configuration of Github Provider.
- Add Handler for Next-Auth
- Sign in and Sign out using next-auth.
- Session in API Routes
- Use session in the Server Components
- Use of session in the Client Components.
1. Set up the Next.js app with the App router.
Follow this document to create a basic next.js app with an app router.