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

@beuluis/regis-tag-me

v2.0.0

Published

Defines react based custom elements and validates the attributes

Readme

Contributors Forks Stargazers Issues

About The Project

Defines react based custom elements and validates the attributes.

Installation

npm i @beuluis/regis-tag-me zod

Usage

import {
    attributeBoolean,
    useWebComponentContext,
    registerWebComponent,
} from "@beuluis/regis-tag-me";
import { z } from "zod";

const MyCustomElement = ({
    firstName,
    showGreeting = true,
}: {
    firstName: string;
    showGreeting: boolean;
}) => {
    const { containerElement, element, hasShadowDom, stylesContainer } =
        useWebComponentContext();

    return (
        <div>
            Hello {firstName} from {element.tagName}. I am{" "}
            {hasShadowDom ? "" : "not"} rendered in a shadow DOM.
        </div>
    );
};

registerWebComponent(
    "my-custom-element",
    MyCustomElement,
    z.interface({
        firstName: z.string().default("Guest"),
        useShadow: attributeBoolean,
    }),
    {
        shadowDOM: ({ useShadow }) => useShadow,
    },
);

Use the custom tag in your HTML:

<html>
    <head>
        <script src="yourBundle.js"></script>
    </head>
    <body>
        <!-- Result: Hello John from MY-CUSTOM-ELEMENT. I am rendered in a shadow DOM. -->
        <my-custom-element first-name="John" use-shadow />
        <!-- Result: Hello John from MY-CUSTOM-ELEMENT. I am not rendered in a shadow DOM. -->
        <my-custom-element first-name="John" />
    </body>
</html>

registerWebComponent

Registers a React component as a Web Component (Custom Element) using the given tag name. Takes registerWebComponent as arguments.

useWebComponentContext

Provides a context for the web component. Returns WebComponentContext.

attributeBoolean

Booleans based on attributes can be tricky.

To help with this this library exports attributeBoolean which is a pre-configured schema that parses attribute based booleans correctly.

Example:

<!-- Result: true -->
<my-custom-element this-is-a-bool />
<!-- Result: true -->
<my-custom-element this-is-a-bool="true" />
<!-- Result: false -->
<my-custom-element this-is-a-bool="false" />
<!-- Result: false -->
<my-custom-element />

If this parsing is not wanted or desired you can checkout Zod´s stringbool

Interfaces

registerWebComponent

  • tagName - The name of the custom element
  • Component - The React component to render inside the web component
  • attributeSchema - Zod 4 or Zod 4-mini object schema defining the attributes/props for the component
  • options - Additional configuration options
    • mixin - Optional mixin to extend the web component's functionality. Runs after this library's logic
    • shadowDOM - Controls whether to use Shadow DOM
      • If boolean: directly determines Shadow DOM usage
      • If function: dynamically determines Shadow DOM usage based on attributes. This only takes effect on the first render

WebComponentContext

  • containerElement - The element to mount the web component in
  • element - The web component element
  • hasShadowDom - Whether the web component uses Shadow DOM
  • stylesContainer - The element to mount custom styles in