- Implemented custom session management using NextAuth.js with JWT strategy.
- Full session persistence, including custom data such as
token
,name
, andemail
. - Seamless integration with Next.js pages for smooth session handling.
- A scalable solution for managing sessions in large-scale projects.
- Set up NextAuth.js with the JWT strategy.
- Authenticate a user and attempt to access the session data.
- The session object will only include basic fields (e.g.,
name
,email
), with custom fields such astoken
missing.
- Clone this repository into your Next.js project.
- Set up NextAuth.js using the Credentials Provider and JWT strategy as demonstrated in the code.
- Run your project and check the session data across different pages.
- The session object will now contain custom fields such as
token
,name
, andemail
across all pages of the app.
- Complete Session Data: Ensures that the session includes all necessary fields like
name
,email
,token
, and custom data. - JWT Strategy: Utilizes the JWT strategy, ideal for scalable applications requiring stateless authentication.
- Persistence Across Pages: Session data is accessible on every page and automatically updates upon user login.