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

storybook-live-code-sandbox

v0.1.2

Published

Preview-iframe Storybook live composition sandbox built with CodeMirror and react-live.

Downloads

120

Readme

storybook-live-code-sandbox

storybook-live-code-sandbox provides one persistent composition workspace for Storybook. Stories send their displayed source to a dedicated sandbox story; individual previews do not mount drawers, launchers, or sandbox providers.

The package is design-system agnostic. It ships core behavior, a default artifact, and a Crossroads UI adapter contract without depending on Crossroads UI.

Install

npm install storybook-live-code-sandbox

Dedicated Sandbox Story

Create one full-screen Storybook story and keep live component references in the preview runtime:

import type { Meta, StoryObj } from "@storybook/react-vite";
import { LiveCodeSandboxProvider } from "storybook-live-code-sandbox";
import { addons } from "storybook/preview-api";
import "storybook-live-code-sandbox/styles.css";
import { liveCodeRegistry } from "../src/liveCodeRegistry";
import { liveCodeScope } from "../src/liveCodeScope";

function Workspace() {
  return (
    <LiveCodeSandboxProvider
      channel={addons.getChannel()}
      checkpointInterval={5}
      historyLimit={8}
      registry={liveCodeRegistry}
      scope={liveCodeScope}
      storageKey="my-library-live-code-sandbox"
    />
  );
}

const meta = {
  title: "Tools/Live Sandbox",
  parameters: { layout: "fullscreen" },
  render: () => <Workspace />
} satisfies Meta;

export default meta;
export const Sandbox: StoryObj<typeof meta> = {};

Add Story Source

Use the exact source string already resolved by Storybook's Docs Canvas and pass it unchanged:

import { addStoryToSandboxStorage } from "storybook-live-code-sandbox/storage";

addStoryToSandboxStorage({
  channel: addons.getChannel(),
  code: sourceProps.code,
  storageKey: "my-library-live-code-sandbox",
  storyName: story.name
});

The helper inserts at the saved cursor, creates an immediate Added <story> checkpoint, and broadcasts a storage-key-scoped synchronization event. It does not navigate to or open the sandbox. Empty source or unavailable storage throws without changing the workspace.

Manager links can navigate to the shared host in response to the exported event:

import { LIVE_CODE_SANDBOX_OPEN_EVENT } from "storybook-live-code-sandbox/events";

Preview-side links can request that navigation with requestLiveCodeSandboxOpen(channel).

Registry

export type LiveCodeRegistryItem = {
  name: string;
  importPath?: string;
  description?: string;
  category?: string;
  disabledReason?: string;
  sandboxVisible?: boolean;
  examples: Array<{ name: string; code: string; description?: string }>;
  props?: Array<{
    name: string;
    type?: string;
    required?: boolean;
    defaultValue?: string;
    description?: string;
    importance?: "high" | "normal" | "advanced";
  }>;
  metadata?: Record<string, unknown>;
};

Only entries with sandboxVisible: true appear. Categories create single-select filters; categories with fewer than three visible components are combined under Other. Props are ordered required, high, normal, advanced, then alphabetically.

Configuration

  • scope: names available to react-live while evaluating compositions.
  • registry: visual components, insertion examples, availability, and prop metadata.
  • storageKey: namespace for persisted state and synchronization events.
  • initialCode: optional initial content; the default is empty.
  • checkpointInterval: component/prop insertions per automatic checkpoint. Default 5; 0 disables interval checkpoints.
  • historyLimit: retained checkpoints. Default 8; constrained to 1-50.
  • channel: optional Storybook-compatible channel for cross-frame synchronization.
  • ui: optional LiveCodeSandboxUIAdapter.

Typing checkpoints on blur, paste checkpoints immediately, and story-source transfers checkpoint immediately. Reset remains in the dedicated view and clears code, history, undo/redo state, insertion progress, selection, and pending typing.

UI Artifacts

The default artifact uses the package's accessible fallback controls:

import { defaultLiveCodeSandboxArtifact } from "storybook-live-code-sandbox/artifacts/default";

Design systems can supply render functions for buttons, chips, fields, tabs, dialogs, notifications, and the root surface. The Crossroads export applies the artifact identity while receiving components through an adapter, avoiding a package dependency cycle:

import { createCrossroadsUIArtifact } from "storybook-live-code-sandbox/artifacts/crossroads-ui";

export const artifact = createCrossroadsUIArtifact(crossroadsAdapter);

Persistence

Storage version 3 persists code, cursor, last successful preview code, checkpoints, checkpoint interval, history retention, and insertion progress. Existing version 1 and version 2 data is migrated when read. Browser storage events and scoped channel events keep Docs frames, tabs, and the dedicated preview synchronized.

Release Process

  1. Run npm run release:check.
  2. Install the generated tarball in a consuming Storybook.
  3. Complete manual desktop and mobile testing.
  4. Publish only after explicit approval. Do not combine validation with versioning or publication.