Dashboard runtime library

Overview

The Dashboard Runtime Library written in React, is the backbone that enables building applications within Ubidots with the capability of interacting with dashboard data, events and the Ubidots API.

Getting started

Add the library to your project

Run the following command at the root of the project where you want to add the library

pnpm add @ubidots/react-html-canvas

Peer Dependencies

  • react >= 16.8

  • react-dom >= 16.8

Usage

Wrap your app with the Provider and use hooks to access dashboard data/event

import 
  UbidotsProvider,
  useUbidotsReady,
  useUbidotsSelectedDevice,
  useUbidotsActions,
} from '@ubidots/react-html-canvas';

function DeviceInfo() {
  const ready = useUbidotsReady();
  const device = useUbidotsSelectedDevice();
  const { setDashboardDevice } = useUbidotsActions();

  if (!ready) return <span>Loading...</span>;
  return (
    <div>
      <pre>{JSON.stringify(device, null, 2)}</pre>
      <button onClick={() => setDashboardDevice('device-id')}>
        Select Device
      </button>
    </div>
  );
}

export default function App() {
  return (
    <UbidotsProvider readyEvents={['receivedToken']}>
      <DeviceInfo />
    </UbidotsProvider>
  );
}

API & examples

Go to the project's repo for understanding more about all the available hooks and actions that the library expose.

Last updated

Was this helpful?