Learn AI, Data Science & Business — Earn Certificates That Get You Hired
Live Online Classes in Design, Coding & AI — Small Classes, Free Retakes
Overview
Google, IBM & Meta Certificates – 40% Off
One Coursera Plus subscription covers most Professional Certificates on Coursera.
Unlock All Certificates
This tutorial shows how to configure role-based authorization in a Next.js 13 app using NextAuth. It covers role persistence, middleware, protected routes, and a denied page, with examples for OAuth and credentials configurations.
Syllabus
Intro
Welcome
Getting Started
Starter Code
Options - OAuth profile function
Options - Credentials authorize function
Persisting the role
TypeScript Module Augmentation
Middleware - withAuth wrapper
Environment variables
Trying out the configuration
Analyzing the results
Component changes
Middleware - authorized callback changes
Middleware - Role-Based Access Routing
Denied page
Trying out the new Middleware configuration
Taught by
Dave Gray