Skip to content

React library for ux4iot for easily building IoT web applications

License

Notifications You must be signed in to change notification settings

deviceinsight/ux4iot-react

Repository files navigation

ux4iot-react

ux4iot is a tool for directly communicating with your IoT devices from your web frontend. Your React frontend gets access to Azure IoT Hub's communication primitives without having a custom-built backend middleware translating between IoT Hub and your user interface. No need to design a REST API so that your UI can offer IoT functionality.

Use the hooks in this library to implement your use cases for live data and for controlling devices.

As an example: Using live data in your React application is as easy as writing

const temperature = useTelemetry('myDevice', 'temperature');

in your React components.

This library provides hooks for:

  • useTelemetry - Subscribe to a single telemetry key of a device
  • useMultiTelemetry - Subscribe to telemetry of multiple devices
  • useDeviceTwin - Subscribe to device twin changes
  • useConnectionState - Subscribe to connection state updates of a device
  • useMultiConnectionState - Subscribe to connection states of multiple devices
  • useDirectMethod - Execute a direct method on a device
  • usePatchDesiredProperties - Update the desired properties of the device twin
  • useD2CMessages - Use the raw messages sent by your devices

Prerequisites

In order to use this library you need to have an ux4iot instance deployed in your Azure subscription. Here is a link to a quickstart that explains how to deploy one. Here is the link to the Azure Marketplace offering.

Installation

Install ux4iot-react in your frontend application:

npm install ux4iot-react

Documentation

Check out the Documentation for

  • Additional options
  • Hook API
  • ux4iot Admin SDKs
  • ux4iot Admin API
  • Reference to other related libraries of the ux4iot service

Tests

  • As ux4iot-react does not provide a lot of tests, the main features in this library are tested via integration tests in an internal repository.

Releasing

If you want to release a new version

  • git checkout master
  • Increase the version based on your changed in package.json (usually minor)
  • git commit -m 'Release VERSION'
  • git tag VERSION -m 'Release VERSION'
  • git push
  • git push --tags

The tag pipeline of github actions will build the package and publish it to npm.