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

@josecortez1/c42-react

v0.1.0

Published

React adapter for the headless @josecortez1/c42-core controllers.

Readme

@josecortez1/c42-react

React adapter for @josecortez1/c42-core — the headless, framework-agnostic UI controllers. Every wrapper renders the documented data-c42-* markup and bridges the matching vanilla-TS controller into React's lifecycle: the controller is instantiated on mount, re-synced when options change (via update() when the controller supports it, otherwise re-created), and torn down on unmount.

The component wrappers are generated from packages/core/manifest.json by scripts/generate-wrappers.mjs, so the React surface always tracks the core API.

npm install @josecortez1/c42-react @josecortez1/c42-core react

Usage

import { Accordion } from '@josecortez1/c42-react';
// Bring the component's base styles from @josecortez1/c42-core (optional, headless-friendly).
import '@josecortez1/c42-core/accordion/style.css';

export function Faq() {
  return (
    <Accordion
      multiple
      defaultValue="shipping"
      onChange={(detail) => console.log('open panels:', detail.value)}
    >
      <div data-c42-accordion-item data-value="shipping">
        <button data-c42-accordion-trigger>Shipping</button>
        <div data-c42-accordion-panel>Ships in 24h.</div>
      </div>
      <div data-c42-accordion-item data-value="returns">
        <button data-c42-accordion-trigger>Returns</button>
        <div data-c42-accordion-panel>30-day return policy.</div>
      </div>
    </Accordion>
  );
}
  • Options as props — every controller option is a typed prop (multiple, collapsible, defaultValue for Accordion). They map straight to the @josecortez1/c42-core AccordionOptions type.
  • Events as onX callbacks — each data-c42-* DOM event becomes a callback receiving the unwrapped event.detail (and the original CustomEvent). accordion:changeonChange.
  • children or default markup — pass your own markup as children. If you omit it, the wrapper renders the manifest's skeleton so the component works out of the box.
  • as prop — override the root element/tag (defaults to the documented root, e.g. "div" for Accordion, "nav" for Nav).
  • Extra props — anything else (e.g. id, aria-*, style) is forwarded to the rendered root element.

Low-level escape hatches

For controllers without a dedicated wrapper, or for full control, use the generic primitives:

import { C42, useC42, useC42Events } from '@josecortez1/c42-react';
import { Tabs } from '@josecortez1/c42-core/tabs';

// Declarative:
<C42 controller={Tabs} options={{ activationMode: 'manual' }}
     events={{ 'tabs:change': (d) => console.log(d) }}>
  {/* …data-c42-tabs markup… */}
</C42>;

// Imperative hook:
function MyTabs() {
  const ref = useC42(Tabs, { orientation: 'vertical' }, ['vertical']);
  useC42Events(ref, { 'tabs:change': (detail) => console.log(detail) });
  return <div ref={ref}>{/* …markup… */}</div>;
}

useC42(ControllerClass, options?, deps?)

Returns a ref to attach to the controller's root element. On mount it runs new ControllerClass(el, options); on unmount it calls destroy(). When any value in deps changes it re-syncs: it calls instance.update(options) when the controller exposes update(), otherwise it destroys and re-creates the instance. SSR-safe — the DOM is only touched inside useEffect.

Development

The wrappers are generated, not hand-written:

node scripts/generate-wrappers.mjs   # regenerate src/components/* and barrels
npm run build                        # vite library build (ESM + d.ts)

License

MIT © Laravel42