To use JWT in our application, we will need to install a library both in our Express web server and in our Angular application. For our web server, we will use jwt-express, a very handy and easy-to-use JWT library for Express. We will use this library to create our JWT, as well as refresh it automatically when we get follow-up requests within a 15-minute expiration window:
npm install jwt-express --save
For Angular, we will install the popular angular2-jwt library. We will use this library to decode our JWT and read our user details from it, as well as make sure that its not expired:
npm install angular2-jwt --save
Finally, we will configure angular2-jwt and add some custom utilities in a new module. We should create this module using Angular CLI's generate command:
ng generate module jwt