AWS IoT: Subscribe to Topic in Browser

Question:

I’m currently developing a Serverless App with AWS.

I want to subscribe to a topic using plain JavaScript (No Node.js, React, Angular etc.)

The IoT and IoTData SDK’s doesn’t support a “subscribe to topic” function.

To achieve this, i need to implement the aws-iot-device sdk, via require('aws-iot-device') (which i can’t use in plain JS).

Unfortunatly this SDK only works with runtimes like Node.js or Browserify.
So how can someone subscribe to a topic from browser? Is there a way to implement the SDK into plain JS?

Thanks in advance

Answer:

This is how its done, works perfectly fine:

cp this libaries into your html.

With this code, you can subscribe to IoT Topics in plain client side JavaScript. No Node.js, React.js or similar is needed!

Leave a Reply