Next.js Protected API Routes (with NextAuth)

Are you looking to protect your Next.js API routes? In this video, I’ll show you how to use NextAuth to implement protected routes in Next.js. This is a great way to secure your application and ensure that only authorized users have access to certain routes. I’ll walk you through the process step-by-step, making it easy to understand and implement on your own. Not only will this tutorial be useful for those new to NextAuth but also for those who want to improve their Next.js application security. So, watch now and learn how to protect your Next.js API routes with NextAuth.

Learn Programming (Skillshare FREE trial): https://skl.sh/3cYxUP5
Repository for the app in the video: https://github.com/tumetus/next-js-protected-api-routes-example

My courses:
React basics: https://skl.sh/2XAKn7u
HTML & CSS for beginners: https://skl.sh/34wvGUH
Draft.js basics: https://skl.sh/3cJ5Hw4

💻 MY GEAR
MY CODIGN LAPTOP: https://amzn.to/3MI90ci
MY MOUSE: https://amzn.to/3mr3no9
MY KEYBOARD: https://amzn.to/3GIoMjh
MY MICROPHONE: https://amzn.to/3KCDPfv
MICROPHONE BOOSTER: https://amzn.to/43trLWB
MY MICROPHONE ARM: https://amzn.to/3oaf5DW
MY CAMERA: https://amzn.to/3UxyvyJ
MY STREAMING LIGHT: https://amzn.to/3KE0PuE

Connect with me:
Website: https://tuomokankaanpaa.com
My newsletter: https://tuomokankaanpaa.com/newsletter
Twitter: https://twitter.com/tumee
Skillshare: https://www.skillshare.com/r/user/tume

Timestamps
00:00 Learn how to create Protected routes with Next.js
00:09 Application initial setup
00:33 Steps we will take
01:22 How to setup NextAuth
01:49 Closer look on the […nextauth].js file
03:04 Creating GitHub application for authentication
04:39 Adding Github secrets to environment variables
06:15 Adding SessionProvider for the app
07:39 Adding Login button
08:28 Testing to log in using Github
09:50 Creating the protected API route
10:49 Adding session check for the protected API route
12:46 Testing the protected API route
14:26 How to use NextAuth with Next.js 13 app folder