From the course: React: Authentication

Unlock this course with a free trial

Join today to access over 24,800 courses taught by industry experts.

Adding JWTs to sign-up and log-in pages

Adding JWTs to sign-up and log-in pages - React.js Tutorial

From the course: React: Authentication

Adding JWTs to sign-up and log-in pages

- [Instructor] Alright, so now that we have the useToken and useUser custom hooks, let's integrate those into our pages, and we'll start off here with the login page and the signup page. Now, both of these pages are going to use the useToken custom hook because neither one of these pages is really going to need to care too much about the user, because they're not going to display the user or anything, right? Really all they need to know is whether the user is currently logged in, and when the user does log in, we're going to redirect the user to that user info page. So the user info page is what's going to use that useUser custom hook, but these ones are going to use useToken. So here's what this will look like. We'll start off by importing useToken. All right, there we go, and that didn't get imported for me automatically for some reason, but we'll just reference that like so. And the other thing that we're going to need here is we're going to need to import a library called axios…

Contents