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

react-slotx

v0.1.1

Published

Slot/Outlet system for React — register content anywhere, render it wherever you place an Outlet. Supports SPA and SSR.

Readme

react-slotx

Slot/Outlet system for React. Declare content anywhere in your tree with <Slot> and render it wherever you place an <Outlet>. Supports SPA and SSR.

Installation

npm install react-slotx

react ≥ 18 is a required peer dependency. react-dom is optional and only needed for SSR.

Core concepts

| Component / Class | Role | | ----------------- | -------------------------------------------------------------------------- | | <SlotProvider> | Provides the shared SlotClient to the tree | | <Slot> | Registers content into a named slot | | <Outlet> | Renders the content of a named slot | | SlotClient | Store — use in SPA | | SlotSSRClient | Store with renderToString — use in SSR (import from react-slot/server) |

SPA usage

import { SlotClient, SlotProvider, Slot, Outlet } from "react-slotx";

const client = new SlotClient();

export function App() {
  return (
    <SlotProvider client={client}>
      <html>
        {/* Outlet can be anywhere in the tree */}
        <head>
          <Outlet name="head" />
        </head>
        {/* Slot registers content from wherever it is rendered */}
        <body>
          <Slot name="head" priority={1}>
            <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
            <meta
              name="viewport"
              content="width=device-width, initial-scale=1.0"
            />
            <title>App Server</title>
            <link
              href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
              rel="stylesheet"
            />
          </Slot>
          <Slot name="content" priority={1}>
            <b>Content</b>
          </Slot>
          <main>
            <div>
              <Outlet name="content" />
            </div>
          </main>
        </body>
      </html>
    </SlotProvider>
  );
}

SSR usage

import { renderToString } from "react-dom/server";
import { SlotProvider } from "react-slotx";
import { SlotSSRClient } from "react-slotx/server";

export function renderPage() {
  const client = new SlotSSRClient();

  const body = renderToString(
    <SlotProvider client={client}>
      <App />
    </SlotProvider>,
  );
  const head = client.renderToString("head");
  const content = client.renderToString("content");

  return `<!doctype html>
<html>
  <head>${head}</head>
  <body>${body} ${content}</body>
</html>`;
}

Outlet modes

The mode prop controls which registered <Slot> the <Outlet> renders when multiple slots share the same name.

| mode | behaviour | | ---------------------- | -------------------------------------------------- | | "priority" (default) | Renders the slot with the highest priority value | | "first" | Renders the first slot registered | | "last" | Renders the last slot registered | | "all" | Renders all slots in registration order |

<Outlet name="head" mode="priority" />
<Outlet name="head" mode="all" />

API

<SlotProvider>

| prop | type | default | description | | ---------- | ------------ | -------- | --------------------------------------------------- | | client | SlotClient | internal | Pass an explicit client instance. Required for SSR. | | children | ReactNode | — | |

<Slot>

| prop | type | default | description | | ------------------------- | ----------- | ----------- | ---------------------------------------------------- | | name | string | "default" | Slot name to register into | | priority | number | 1 | Higher value wins when mode="priority" | | children | ReactNode | — | Content to register | | dangerouslyEnableRender | boolean | false | Also renders children in-place (not just via Outlet) |

<Outlet>

| prop | type | default | description | | ------ | ------------------------------------------ | ------------ | -------------------------------------------- | | name | string \| "*" | "default" | Slot name to render. "*" matches all slots | | mode | "priority" \| "first" \| "last" \| "all" | "priority" | Selection strategy |

SlotClient

const client = new SlotClient();

SlotSSRClientreact-slot/server

import { SlotSSRClient } from "react-slotx/server";

const client = new SlotSSRClient();
// after renderToString(...):
const html: string = client.renderToString("slot-name");
const html: string = client.renderToString("slot-name", { mode: "all" });

Resources

Git Repository https://github.com/yracnet/react-slotx/

SPA Example https://github.com/yracnet/react-slotx/tree/main/examples/my-spa-app

SSR Example https://github.com/yracnet/react-slotx/tree/main/examples/my-ssr-app

Package https://www.npmjs.com/package/react-slotx

Tutorial https://dev.to/yracnet/react-slotx-4khe

License

MIT