From the course: React: Authentication (2021)

Unlock the full course today

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

Implementing JWTs on the front end

Implementing JWTs on the front end - React.js Tutorial

From the course: React: Authentication (2021)

Implementing JWTs on the front end

- [Instructor] Okay. So we've created two routes on our backend now for allowing users to create an account and log in with the credentials that they've specified. So now that we have that logic available to us on the backend, it's time to add logic on the front end to integrate JWTs. Now, one way that we could do this would be to simply add that logic directly to our login page and sign up page. But one are the nice things that React allows us to do via hooks is define this logic once, and then simply import it into both our signup and login pages and use it there. You'll see what I mean in just a minute. So the basic idea of what we're going to do here is this. When a user clicks signup, or login, on our respective pages that we have here, both those pages are going to make a request to the corresponding route on the backend, which as we've seen will return a JSON web token containing the user's data. And then what…

Contents