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

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