From the course: Next.js 14 from Scratch: Build a Real-World Project Using Next.js 14 and MongoDB
Unlock this course with a free trial
Join today to access over 25,200 courses taught by industry experts.
NextAuth and provider setup - Next.js Tutorial
From the course: Next.js 14 from Scratch: Build a Real-World Project Using Next.js 14 and MongoDB
NextAuth and provider setup
All right, guys. So we're going to be using NextAuth for authentication, which is a fantastic package. You can use so many different providers. So we'll be using Google. But if you go to the documentation and then providers, you can see there's just a ton of them. All right. So what we want to do in this video is basically create our provider array and implement the Google provider. So if we click on Google, which is right here. Actually, I'm already on the page. So we want to basically import the Google provider. We need to pass it into the providers array and add our client ID and secret, which we already have. We did that in the last video. And then there's some other options that we need to add. And then we can add our callbacks for when we sign in and when we create a session. When we sign in, we're going to want to save the user to the database if they're not already saved, because we want the users' e-mail, the image, the Google image that they use, and stuff like that so they…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.