Next.js Middleware Crash Course || App Router Protected Routes

Опубликовано: 04 Ноябрь 2024
на канале: tapaScript by Tapas Adhikary
10,302
451

Enjoy my videos & teaching? Join tapaScript as a member:
   / @tapasadhikary  

Do you find Next.js Middleware difficult to understand, and challenging to use? Here is a crash course for you where you will learn:

What is middleware?
The app structure
Create a middleware
What is a matcher?
Middleware and Route handlers
Auth in middleware: The problem
Auth Config - The solution
Declaring private and protected routes
Handling protected and public routes in middleware
Protecting subroutes in middleware
Oauth providers(Google, GitHub) and middleware
Protecting API routes

Finally, a task for you to implement how an admin alone can access the dashboard after authentication. Let's GO 🚀

Catch up with the previous video on Persisting Users to DB:    • Next.js Authentication || Register Us...  

Hey, welcome back to another informative video from the "Full Stack With Next.js App Router" series. I hope you enjoy this one the same way you liked the previous videos from the series.

I take special care to provide you the best quality content. Please SUBSCRIBE to the channel to show your support. Also, could you like/comment on this video so that it reaches others? Thanks! 🫶

Timecodes
0:00 - We Will Learn These
01:26 - What is middleware?
05:58 - The app structure
16:51 - Create a middleware
20:10 - What is a matcher?
24:57 - Middleware and Route handlers
26:09 - Auth in middleware: The problem
31:13 - Auth Config - The solution
36:21 - Declaring private and protected routes
39:13 - Handling protected and public routes in middleware
47:40 - Protecting subroutes in middleware
50:30 - Oauth providers(Google, GitHub) and middleware
52:54 - Protecting API routes
59:46 - What's Next?

Videos mentioned:
   • JavaScript Object Destructuring 101 -...  
   • Do We Need These JavaScript Operators...  

Source Code on tapaScript GitHub:
https://github.com/tapascript/learn-n... (If you like, please support the project with a ⭐)

Join tapaScript
Join tapaScript as a member:    / @tapasadhikary  
Join Discord:   / discord  

🤝 My Links:
Blog: https://blog.greenroots.info/
Follow on X(Twitter):   / tapasadhikary  
Connect on LinkedIn:   / tapasadhikary  
Follow My Work on GitHub: https://github.com/atapas
Follow on Facebook:   / tapasadhi  

Special Links:
If you are looking for the best content management system, here is something for FREE that you can rely on: https://app.caisy.io/app/signup/mwiyy...

👋 Like my work? Thank You. You can sponsor me from here:
Sponsor Me: https://github.com/sponsors/atapas
Sponsor my Blog: https://blog.greenroots.info/sponsor

About Me:
Tapas Adhikary is an Educator at tapaScript, Tech enthusiast, Writer, YouTuber, and Open Source projects maintainer/contributor. He is a full-stack developer with vast experience in building SaaS solutions. He is the founder of the ReactPlay platform, which is driven by open-source projects and a fast-growing community.

You can find more about him at https://tapasadhikary.com.

#nextjstutorial
#next
#nextjs14
#nextauth
#authentication
#nextjs
#nextjs13
#nextjsapprouter
#thinkinginnextjs
#nextjstutorial
#next-auth
#authjs
#middleware