MENU

Fun & Interesting

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

tapaScript by Tapas Adhikary 18,402 11 months ago
Video Not Working? Fix It Now

Enjoy my videos & teaching? Join tapaScript as a member: https://www.youtube.com/channel/UCaYr5yxgOyk599Mnb3TGh-g/join 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: https://www.youtube.com/watch?v=5kmZAqc2Jeg 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: - https://www.youtube.com/watch?v=J8zlaJWn_ig - https://www.youtube.com/watch?v=05Qu9gW7wzs ## Source Code on tapaScript GitHub: - https://github.com/tapascript/learn-next-auth/tree/05-middleware (If you like, please support the project with a ⭐) ## Join tapaScript - Join tapaScript as a member: https://www.youtube.com/channel/UCaYr5yxgOyk599Mnb3TGh-g/join - Join Discord: https://discord.gg/YzUe4DbNAz ## 🤝 My Links: - Blog: https://blog.greenroots.info/ - Follow on X(Twitter): https://twitter.com/tapasadhikary - Connect on LinkedIn: https://www.linkedin.com/in/tapasadhikary/ - Follow My Work on GitHub: https://github.com/atapas - Follow on Facebook: https://www.facebook.com/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/mwiyyiglk2er ## 👋 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

Comment