This is a really good simple library. I had success creating a wrapper for it in Dart.
Now I’m migrating my project that make use of it to kotlin.
This is an example on instantiating a new object of Client in js realm.
client = new Paho.MQTT.Client(location.hostname, Number(location.port), “clientId”);
I read the documentation about the external keyword; but notice the nested object: Paho.MQTT.Client
There you will find one usage example in the firsts lines of comments (line 58)