Skip to content

Demonstrating 3 use cases for setting custom properties to session+JWT token and how to use them in client, middleware and server components

Notifications You must be signed in to change notification settings

madebycm/nextjs-cm-authjs

Repository files navigation

This project demonstrates how to effectively set custom properties in JWT tokens and utilize them across client, middleware, and server components. Built using Next.js 14 and next-auth 4.24. The use cases outlined in this repository illustrate how these custom properties can be used to enhance authentication, manage user sessions, and pass essential information securely between the client and server.

To start:

You will see three use cases for how to access and set custom session properties using next-auth. This can be extended to serve as role-based access controls (RBAC), etc.

This demonstration uses GoogleProvider, so update .env.local with:

GOOGLE_ID="xxx"
GOOGLE_SECRET="xxx"

(or use any other provider)

About

Demonstrating 3 use cases for setting custom properties to session+JWT token and how to use them in client, middleware and server components

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published