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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@kipk/load-ha-components

v2.0.0

Published

Dynamic loader for Home Assistant components

Downloads

246

Readme

Home Assistant Components Loader

@kipk/load-ha-components loads and verifies Home Assistant UI custom elements used by a custom card or panel. It is intended for code running under the Home Assistant DOM tree.

Version 2.x is published as an ES module and exposes a single strict loading API.

Installation

npm install @kipk/load-ha-components@^2.0.0

Usage

import {
  HaComponentsLoadError,
  loadHaComponents,
} from '@kipk/load-ha-components';

try {
  const result = await loadHaComponents(['ha-form', 'ha-icon-button']);
  console.log(result.loaded);
} catch (error) {
  if (error instanceof HaComponentsLoadError) {
    // Pick an application-specific fallback here.
    console.warn('Unavailable Home Assistant components:', error.result.missing);
  } else {
    throw error;
  }
}

loadHaComponents() is the only loading API. It resolves only after every requested custom element is defined, and rejects with HaComponentsLoadError if a strategy fails, times out, the DOM is unavailable, or an element remains absent. The package does not log errors or choose a fallback itself.

The result has requested, alreadyDefined, loaded, missing, and attemptedStrategies arrays. Requests are trimmed, de-duplicated, and retain their first-seen order. timeoutMs is the sole option and defaults to 10 seconds when omitted or invalid.

Loading strategies

Most components use Home Assistant's Configuration/Automations loading path. ha-target-picker and ha-date-range-picker use the History panel bundle instead:

await loadHaComponents(['ha-target-picker']);

The loader feature-detects Home Assistant's panel resolver helpers, shares concurrent strategy loads, and retries a strategy after a failure or an import that did not define the requested element. It does not guarantee that an arbitrary unknown internal component can be loaded: unknown names use the historical Configuration/Automations strategy and still fail strictly if absent.

ha-target-picker relies on Home Assistant context. Render it below the <home-assistant> tree so its Lit Context providers, including labels, are available; loading its module alone does not make it work outside that tree.

Migrating from 1.x to 2.x

Version 2.0.0 deliberately changes the contract. Previously, loading failures were caught and hidden. In 2.x, callers must handle the rejected promise at the UI boundary where an appropriate fallback can be selected.

Existing consumers that declare ^1.0.3 do not select this major version and remain on the compatible 1.x line until they migrate explicitly.

try {
  await loadHaComponents(['ha-target-picker']);
  // Render the picker only after successful verification.
} catch (error) {
  if (error instanceof HaComponentsLoadError) {
    // Keep the editor in a safe state or render a local fallback.
  } else {
    throw error;
  }
}

Default components

The following components are included in the default list:

  • ha-form
  • ha-icon
  • ha-icon-button
  • ha-selector
  • ha-textfield
  • ha-icon-picker
  • ha-entity-picker
  • ha-select
  • ha-dialog
  • ha-sortable
  • ha-svg-icon
  • ha-alert
  • ha-button
  • ha-color-picker
  • ha-badge
  • ha-sankey-chart

License

MIT