From the course: React: Authentication

Unlock this course with a free trial

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

Generating JSON Web Tokens

Generating JSON Web Tokens - React.js Tutorial

From the course: React: Authentication

Generating JSON Web Tokens

- [Narrator] All right, so now that we've created our signup route on our server, we need to actually add jsonwebtokens into this. Now, there are a lot of different packages that you can use for doing this, but the one that we're going to use is the most straightforward, and that is jsonwebtoken. So just like we did with the other packages, we're going to need to install this one. So you can actually just open up, well here, we'll open up the same one that we had. We're going to say npm install jsonwebtoken, all one word, no dashes, nothing. And that will install that for us. So now that we've done that, here's how we add this to our signup route. First of all, we'll just add this in as an import. We'll say const jwt = require jsonwebtoken. All right, now that we've done that, let's actually scroll down to where we're going to need to generate that token. So, this is going to be after we've inserted the user into the database, right? So, we've already added the user to the database…

Contents