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

react-widget-repository

v1.0.5

Published

Makes it easy to work with react widgets

Readme

React Widget Repository

Makes it easy to work with react widgets rendered by the server.

Install

npm install --save react-widget-repository

Basic usage

Suppose you have a HelloWorld react component, which should be a hello-world widget.

in your html:

<div is="hello-world" data-name="Elvis Presley">Hi</div>

in your js:

// import the repository singleton
import repository from "react-widget-repository";
// import your component
import HelloWorld from "components/hello-world";

// register the component (register all your widget like components)
repository.register("hello-world", HelloWorld);
// and run it
repository.run();

It will render your component into the div, which has the is="hello-world" attribute.

Props

Repository will pass all data-attributes as props to your component, including the tag's content as innerHtml to work with. Therefore you can pass complex data to the widget within innerHTML as JSON.

{
	"name": "Elvis Presley",
	"innerHTML": "Hi"
}

Hide not-yet-rendered widgets

You can hide your not-yet-rendered widgets, with css. Because the repository manager removes the is attribute from the widget tag, it's easy.

// hide every or specific widgets before rendering
[is]{display:none;}
[is="hello-world"]{display:none;}

Turn on DOM observer

You can initialize the repository with observer (just pass true to the run method, or call the observe() method). From this, it listens to DOM changes, and handles every dynamycally added widgets.

repository.run(true);

Modify the is attribute

You don't need to use the is attribute to work with widgets.

<div widget="hello-world" data-name="Elvis Presley">Hi</div>
repository.register("hello-world", HelloWorld);
repository.widget_attr = "widget";
repository.run();

Self registering component

You can create self registering components. You don't need to collect every component on every page to register manually. Just import what you need, and your components will do the rest. (don't forget to call the repository.run() method!)

import React from "react"
import repository from "react-widget-repository";

export default class HelloWorld extends React.Component {
	// ...
}

repository.register("hello-world", HelloWorld);

debug()

The repository has a debug() method. It will print out the list of the registered widgets and warnings to the console.

Warning types are:

  • duplicate - the same component is already registeredwith the same widget name
  • overwrite - you are registering an already registered widget, but with an other component
  • not-found - you mention an unregistered widget

You can call this method whenever you want to.

You may register it globally and call it from the console:

window.rwr = repository;

in the console: rwr.debug()