How do I use external libraries?

Question on using custom code https://docs.retool.com/docs/custom-js-code

When i try to add a CDN for external library, and save, i don’t really get a message as shown in the page. like : Added the Papa Parse library from a CDN.

Is there any time gap between when the library is actually available and when it is saved ? and is the absence of confirmation message just a bug ?

For ex. I tried adding https://cdnjs.cloudflare.com/ajax/libs/jsSHA/3.2.0/sha.js and didnt get any confirmation. But i could not find any jsSHA object/function being available after that.

For anyone stuck like me. The function is usable. I ended up using https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/crypto-js.min.js and even though the linter shows an error with red underlining, the functions are still accessible

Thank you @victoria for helping out with this

2 Likes

I added the same Library, but can't access it, Once I hit the add button, what else must I do?
Any Guidance would be helpful.

Thanks

Hey @craigboiseusr! Once you add the library, you should be able to use it. Here are some screenshots:
1) Add the library in the 3 dot menu under Scripts and styles

2) Use a function from that library in a query, transformer, etc


3) In this case, you should be able to see the hashed version of the string.

How would I go about doing this for a parquetjs library to read GCS signed objects in retool? I added https://cdn.jsdelivr.net/npm/edge-impulse-parquet@1.0.9/edge-impulse-parquet/index.min.js as described but I can't use it in a transformer.

var parquet = require('node-parquet');
var reader = new parquet.ParquetReader({{gcsSignedParquet.data.body}});
console.log(reader.info());
console.log(reader.rows();
reader.close();

After running I get back "require not found" or when I remove the first line "can not find parquet".

as per edge-impulse-parquet - npm

Hey grffxbio, unfortunately not every library is compatible with Retool right now. That one that you are using has require calls in it, which won't work inside of Retool. If there is a version that uses module.exports like the crypto-js library referenced above, then you should be able to use it.

hello @joeBumbaca
I am trying same thing for https://cdn.jsdelivr.net/gh/tomik23/circular-progress-bar@1.1.9/dist/circularProgressBar.min.js but no success , can you check on this: Create a circular progress bar for table cell data - #2 by victoria