Apart from the dev tools that the developer platform offers, you can also use external libraries in your app logic, to avail the functionalities that these libraries extend. You can use front-end libraries to enhance your app’s front-end capabilities or npm packages to enhance your app’s back-end functionalities.
This section provides information on how to include these libraries in your app project and how to use them in your app code.
Include front-end libraries
From the app’s root directory, navigate to the file that contains the logic to render the app’s front-end component (index.html or template.html). Use the syntax shown on the right pane, to include a front-end library that enhances your app’s functionality.
Important:The support for the unpkg CDN has been discontinued for both self-hosted and third-party libraries in frontend apps. Use any alternative CDNs when importing libraries for your frontend apps.
Include npm packages
- In manifest.json, register the npm package, which you intend to use, as a dependency.
- In server.js, use require("<npm-package-name>") to start using the package.
How to use npm packages and enable your app to place a JWT request?
A JSON Web Token (JWT) is a JSON based way of securely transferring information between two parties. For your app to place a JWT request,
- In manifest.json, register the following npm packages as dependencies: jsonwebtoken and request
- In server.js, use require("<npm-package-name>") to start using the packages.
- In your app code, generate the jwt token by signing the payload that must be sent in the request with a secret/private key. The jsonwebtoken package helps with this.
- When constructing the request, use the JWT token in the Authorization header. The request package helps place the request.
For a sample, see the code on the right pane.