Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

YouTube

JWT Authentication - Persist Login State on Refresh - MERN Stack

Dave Gray via YouTube

Overview

Google, IBM & Meta Certificates – 40% Off
One Coursera Plus subscription covers most Professional Certificates on Coursera.
Unlock All Certificates
This course demonstrates JWT authentication in a React MERN application, including authorization headers, refresh-token reauthorization, RTK Query integration, and persistent login state after page refresh. It assumes familiarity with Node.js, React, and Redux Toolkit.

Syllabus

Intro
Welcome
Starter Code & User Stories
Send access token with a baseQuery
Test the baseQuery requests
baseQueryWithReauth wrapper function
Test the baseQueryWithReauth requests
Fix for useQuery when it doesn't unsubscribe
usePersist custom hook
Add Persist toggle to Login form
Quick CSS addition
Persist Login component
Set credentials with onQueryStarted
Add PersistLogin to App.js
Test the Persistent Login State
Terminology 'labels' vs 'cache entries': When different values are placed here, different caches are created. In the upcoming 'Refactor' chapter 12 video, we insure all queries use the same cache entry value to avoid creating additional caches.

Taught by

Dave Gray

Reviews

Start your review of JWT Authentication - Persist Login State on Refresh - MERN Stack

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.