How to use external NPM library correctly in Retool?

I am trying to load this library in Retool, and use it in scripts triggered by a click on the button component:
https://cdn.jsdelivr.net/npm/jsonwebtoken@8.5.1/index.js

I have tried to load it according to documentation: https://docs.retool.com/docs/custom-js-code

But I still cannot access it in the script. How can I load it properly?

Hi @kghugo

the library you're trying to use if for Node.js only.
You cannot use it in browser.

If you need only the decoding function, there's a specific library from the same author for browser use-case:

Hope this help

1 Like