From the course: Learning Next.js
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Solution: Authenticate and create posts
From the course: Learning Next.js
Solution: Authenticate and create posts
So now the challenge is to create a new blog post and make sure that we also provide with the user information. So, make sure that you are connected and provide the name of the user who is connected. So let's go to our Projects and the first thing I want to do. So that's going to be right here, I want to add a new state variable. And that's going to be to keep the information of the user. So at first, it's going to be null. And something we're going to do as well as part of this exercise is to create a new type definition. So just like we've done for the post, we're going to create a new user type. And every user comes with the information of the name, email, and then image. Every time that you sign in. So it can be string type or undefined or null. It could be either one. So I'm going to update also for the other properties like this. All right. And once this is done, so we're going to add this to the scope. Let's put that at the top level. And we're going to import this new user…
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Getting started with NextAuth.js52s
-
(Locked)
Setting up NextAuth.js3m 19s
-
(Locked)
Creating the auth routes and components4m 27s
-
(Locked)
Adding the Google credentials provider5m 22s
-
(Locked)
Sign in with your Gmail account5m 49s
-
(Locked)
Challenge: Authenticate and create posts1m 54s
-
(Locked)
Solution: Authenticate and create posts7m 17s
-
(Locked)
Protecting pages and API routes6m 1s
-
(Locked)
-
-