npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@ubidots/react-html-canvas

v0.2.1

Published

React library to interact with Ubidots Dashboards from HTML Canvas widgets (Provider + hooks + actions)

Readme

@ubidots/react-html-canvas

React library to interact with Ubidots dashboards from HTML Canvas widgets.

Instalación

pnpm add @ubidots/react-html-canvas

Peer Dependencies

  • react >= 16.8
  • react-dom >= 16.8

Basic Usage

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

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

  • Provider

    • UbidotsProvider(props)
      • props:
        • onReady?: () => void
        • readyEvents?: ("receivedToken" | "receivedJWTToken" | "selectedDevice" | ...)[]
        • validateOrigin?: (origin: string) => boolean
        • initialStateOverride?: Partial
  • Hooks

    • useUbidotsReady(): boolean
    • useUbidotsToken(): string | null
    • useUbidotsSelectedDevice(): Device | null
    • useUbidotsSelectedDevices(): Device[] | null
    • useUbidotsDashboardDateRange(): DateRange | null
    • useUbidotsRealTimeStatus(): boolean | null
    • useUbidotsDeviceObject(): DeviceObject | null
    • useUbidotsDashboardObject(): DashboardObject | null
    • useUbidotsSelectedFilters(): Filter[] | null
    • useUbidotsWidget(): { settings: object; id: string } | null
    • useUbidotsActions(): Actions
    • useUbidotsAPI(): Ubidots API client (autenticado con token)
  • Acciones (useUbidotsActions)

    • setDashboardDevice(deviceId: string)
    • setDashboardMultipleDevices(deviceIds: string[])
    • setDashboardDateRange(range: { startTime: number; endTime: number })
    • setDashboardLayer(layerId: string)
    • setRealTime(rt: boolean)
    • refreshDashboard()
    • openDrawer({ url: string; width: number })
    • setFullScreen('toggle' | 'enable' | 'disable')
    • getHeaders(): { Authorization | X-Auth-Token, Content-type }

Examples & Documentation

📚 Complete Documentation

See the docs/ folder for comprehensive API documentation:

  • Provider: UbidotsProvider
  • Hooks: Individual documentation for each hook
  • Types: TypeScript interfaces and types
  • Guides: Setup, patterns, and best practices

🎯 Working Examples

See the examples/ folder for complete working examples:

Configurable Ready State

You can control which events must occur before considering the system "ready":

<UbidotsProvider readyEvents={['receivedToken', 'selectedDevice']} />

Notes

  • The vanilla library (ubidots-html-canvas) was used as reference for events/methods. It's not a runtime dependency.
  • The useUbidotsAPI hook exposes an SDK client and authenticates it when the token arrives.

Development

Code Quality

This project uses ESLint for linting and Prettier for code formatting to ensure consistent code style.

Available Scripts


# Install dependencies
pnpm install

# Run linter
pnpm run lint

# Run linter with automatic fixes
pnpm run lint:fix

# Format code with Prettier
pnpm run format

# Check if code is properly formatted
pnpm run format:check

VS Code Integration

If you're using VS Code, the project includes settings that will:

  • Format code automatically on save
  • Run ESLint fixes on save
  • Show linting errors and warnings inline

Make sure you have the following VS Code extensions installed:

Configuration Files

  • eslint.config.js - ESLint configuration with React, TypeScript, and accessibility rules
  • .prettierrc - Prettier formatting configuration
  • .editorconfig - Editor configuration for consistent coding styles
  • .vscode/settings.json - VS Code specific settings

CI/CD Pipelines

This project uses GitHub Actions for continuous integration and deployment:

Pull Request Checks (.github/workflows/pr-checks.yml)

Runs on every PR and push to main/develop branches:

  • Code Quality & Tests: Runs on Node.js 18 and 20
    • TypeScript compilation check
    • ESLint code quality check
    • Prettier formatting verification
    • Unit tests execution
    • Build verification
  • Security Audit: Checks for vulnerabilities in dependencies
  • PR Summary: Posts automated summary comment on PRs

Deployment Pipeline (.github/workflows/deploy.yml)

Manual deployment workflow with the following features:

  • Manual Trigger: Only runs when manually triggered from GitHub Actions
  • Version Selection: Choose patch, minor, or major version bump
  • Pre-release Support: Optional tag for beta/alpha releases
  • Quality Checks: Full linting, testing, and build verification
  • Automated Versioning: Bumps version and creates git tags
  • NPM Publishing: Publishes to NPM with appropriate tags
  • GitHub Release: Creates release with installation instructions

How to Deploy

To deploy a new version:

  1. Go to the Actions tab in GitHub
  2. Select the Deploy workflow
  3. Click Run workflow
  4. Choose the version bump type (patch/minor/major)
  5. Optionally add a pre-release tag (e.g., "beta")
  6. Click Run workflow

The deployment will:

  • Run all quality checks
  • Bump the version in package.json
  • Create a git tag
  • Publish to NPM
  • Create a GitHub release

License

MIT