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

@embeddables/workbench

v0.3.2

Published

Floating Workbench panel for testing Embeddables experiments and forms on a host page.

Readme

@embeddables/workbench

Floating panel a host mounts beside its own page. Operators use it to inspect and switch experiment variants on a live page.

npm install @embeddables/workbench @embeddables/core @embeddables/experiments

@embeddables/core and @embeddables/experiments are what the host page already uses to assign variants; the panel takes the experiments client from them. Without them, the panel still mounts, but Variants has nothing to switch.

The panel is a React component. initWorkbench() does not render it.

Mount

Import Workbench from @embeddables/workbench/react and @embeddables/workbench/styles.css once from the host. Render <Workbench enabled={import.meta.env.DEV} /> in the same tree as the page.

The panel mounts when enabled is true, when the page hostname is on *.embd.co (Embeddables preview deploys, even if enabled is false or omitted), or when the page URL has workbench=true. The query value must be exactly true. On production domains and on localhost, it otherwise stays unmounted. Until one of these gates passes, the host does not load the bundled or remote panel module.

The shell does not import Core, Experiments, Forms, or Protocols. Boot those in the host and pass the clients in.

Inside EmbeddablesProvider, import Workbench from @embeddables/workbench/embeddables instead. It fills Data from the provider's forms() module and Core's form schemas, so the host passes no forms wiring. Data writes reach the page only where components read values through the forms SDK; for button and option steps, follow Steppers and option steps. @embeddables/core is an optional peer used only by that entry. If the installed Core predates getFormIds on useEmbeddables(), pass formSchemas={config.forms}. Without the provider, build the client yourself with createFormsWorkbenchClient({ forms, schemas: config.forms }) from the package root. Operator sign-in and reads (live split, Review, Hosting) use the panel's own client against the Embeddables API; the host installs nothing extra for them.

Example:

import { EmbeddablesProvider, useEmbeddablesModule } from '@embeddables/core/react'
import { experiments } from '@embeddables/experiments/react'
import { Workbench } from '@embeddables/workbench/react'
import '@embeddables/workbench/styles.css'

import { config } from './embeddables/_dist/config.ts'

function App() {
  const registered = useEmbeddablesModule({ key: 'experiments' })
  if (registered === null) return null

  return (
    <>
      <YourPage />
      <Workbench
        enabled={import.meta.env.DEV}
        enabledModules={config.enabledModules}
        projectId={config.projectId}
        experimentsClient={registered.client}
      />
    </>
  )
}

export function Root() {
  return (
    <EmbeddablesProvider config={config} modules={[experiments()]}>
      <App />
    </EmbeddablesProvider>
  )
}

experimentsClient is the client EmbeddablesProvider registered for the experiments module. A variants click calls setVariant on it, so useExperiment on the host page renders that variant. The panel does not write the sticky assignment.

Variants opens on "On this page": the experiments a mounted useExperiment renders right now. "All experiments" lists every experiment the client is configured with, so you can force a variant for a page before you reach it. "Clear overrides" shows when a variant is forced.

Routes inside the panel always use an in-memory router (createMemoryRouter), so switching panel tabs never modifies the host page's URL or hash. The host page keeps its own history.

<Workbench> renders the panel in its own React root on document.body, not inside your tree. Your providers and context do not reach it, so pass everything as props. It shows up as a separate tree in React DevTools. The panel re-renders only when a prop changes by reference, so create clients and arrays once (module scope or useMemo) instead of inline.

react-router@7 is a peer dependency; install it in the host even if the host has no router of its own.

Navigate lists the host's pages from your routes:

  • <RouterProvider> (createBrowserRouter) and framework mode (react-router build): detected, no prop.
  • <BrowserRouter> + <Routes>: replace <Routes> with <WorkbenchRoutes> from @embeddables/workbench/react; a sibling <Workbench /> finds the routes with no prop.
  • To choose the pages yourself, or if detection fails (Navigate is missing and the console warns), pass navigationClient={createRouterNavigation(router)}, or in framework mode navigationClient={useRouteNavigation(workbenchRoutes)} from the root route with a module-level RouteObject[]. An explicit navigationClient always wins.

Labels come from handle.workbench.title or handle.title (else a humanized path segment), and :param routes stay disabled until their params are active. How detection works, its limits, and a full framework-mode example: docs/workbench.md.

The panel opens from a round button in the bottom-right corner and closes from its header. It starts closed and remembers open or closed for the tab in sessionStorage (embeddables.workbench.open). The host does not control this.

Peers: react and react-dom >=18.

Sign in

Live weights, Review, and Hosting need an operator session. Everything else works signed out.

  • Any page. Click "Sign in to perform actions" in the panel footer, enter your Embeddables email, and type the code from the email. The session lasts until the tab closes.
  • A page on localhost or 127.0.0.1. Reuse your CLI login instead. Run em login once, then em dev --origin <page origin> (for example em dev --origin http://localhost:5173). It prints the bridge URL (http://127.0.0.1:4317 by default) and a nonce. Pass both as sessionBridge; the nonce changes each time em dev starts, so read it from an env var such as VITE_EM_DEV_NONCE rather than committing it.
const nonce = import.meta.env.VITE_EM_DEV_NONCE

<Workbench
  enabled={import.meta.env.DEV}
  sessionBridge={nonce ? { url: 'http://127.0.0.1:4317', nonce } : undefined}
  /* ... */
/>

Styles

@embeddables/workbench/styles.css is compiled CSS. The host does not need Tailwind. Every rule is scoped to the panel's root element ([data-embeddables-workbench], around both the bubble and the panel), so the sheet does not restyle the host page, and host rules with plain element or class selectors do not override the panel. The root resets inherited text styles (text-transform, letter spacing, font size and weight), and lengths ship in px, so a lowercase body or a changed html font-size on the host does not change the panel. A host rule with an id or a stronger selector can still reach panel elements.

The sheet imports the Figtree and JetBrains Mono fonts from @fontsource, which installs with the package. Import it through a bundler (Vite, webpack, Next) so those imports resolve.

Props

| Prop | Purpose | | --- | --- | | enabled | Mount the panel. Default false. Hostnames on *.embd.co and URLs with the exact query value workbench=true mount the panel regardless. | | enabledModules | The CLI config switch: the enabledModules block from the generated embeddables/_dist/config.ts. A section whose SDK is off is left out of the rail and its route. Omit it and the module gate lets every section through. Events, Review, and Hosting still stay out of the rail until there is an operator session. | | projectId | Project id for operator reads. Live weights, Review, and Hosting send it with operator reads. A host passes the id from generated config. Omit it and those actions say the project id is missing. | | experiments | Optional cards on the variants page. Most hosts omit it: the panel lists the experiments client's configured experiments. A card with the same id replaces the configured one (to rename it or its variants), and other cards are added after them. key, when present, is shown with the id in the info tooltip beside the title. split is ignored; the panel does not render it. Percentages come from the operator experiment read while an operator session is signed in. Signed out, a card shows no percentages and links to sign-in. assignedVariant is a fixture key for a card the client does not know; that card does not show percentages. onPage: false hides the card under "On this page", but only with an experiments client too old to report what the page renders. | | experimentsClient | Host experiments client. Needs initExperiment, setVariant, clearVariant, and readOverride; listExperiments, readRenderedExperimentIds, and subscribeRenderedExperiments drive the card list and "On this page" when present. Omit it and variant override stays off. Weights still require a signed-in operator session. | | formsClient | Session fields for Data. listForms returns one card per form and must keep that same array until subscribe fires. Apply sends only dirty editable fields and does not submit. Omit it and Data says the host passed no forms. | | formSchemas | @embeddables/workbench/embeddables only. Form schemas keyed by form id (config.forms), for Core releases whose useEmbeddables() does not expose getFormIds. | | navigationClient | Page list and host-driven moves for Navigate. Reads getPageList?.() ?? pageList ({ id, title, path?, disabled? }), subscribes to subscribe when present, calls goToNextPage, goToPrevPage, and goToPage, and re-reads getCurrentPage(). Build it with createRouterNavigation(router) or useRouteNavigation(routes). When omitted, <Workbench> uses a parent data router (<RouterProvider>, framework mode) or a sibling <WorkbenchRoutes>. Without any of these, Navigate stays out of the rail. | | protocolsClient | Protocol cards on Data. The host decides eligibility, visibility, and whether a destination is connected. Omit it and the Protocols group stays hidden. | | apiUrl | API origin for operator sign-in and reads. Defaults to https://backend.embeddables.com, or to EMBEDDABLES_API_URL_FOR_DEVELOPMENT when the package was built with it. | | operatorClient | Replaces the panel's own operator client, for tests or a custom transport. Must implement WorkbenchOperatorClient. Most hosts omit it. | | reviewDashboardUrl | Optional URL template for Open full review and each timeline row's Open review link on the Review tab. Replace :projectId and :pullNumber with the current project and pull. The panel appends pull=<number> and, when a review commit is selected (not Head), review_id=<id>; each timeline row links with its own review_id. Omit it and the panel shows that the dashboard URL is not configured. | | sessionBridge | { url, nonce } printed by em dev. Used only when the page hostname is loopback. See Sign in. | | locationHost | Hostname for the loopback and *.embd.co preview checks. Defaults to window.location.hostname. | | locationSearch | Search string for the workbench=true check. Defaults to window.location.search. | | panelUrl | Where the panel UI loads from. Defaults to https://workbench.embeddables.com/v1/panel.js. Pass null to always use the copy bundled in the package. See Remote panel. |

Remote panel

The npm package is a thin wrapper. When the panel first mounts, it imports the panel UI from panelUrl, so panel releases reach a host without a package upgrade. Package upgrades are only needed for changes to props or to the wrapper. If the import fails, times out after 5 seconds, or returns a panel the wrapper does not support, the wrapper logs one console warning and uses the panel bundled in the package.

The remote panel loads its own content-hashed stylesheet and fonts from the same origin. Each panel.js names the exact stylesheet it was built with, so a cached panel.js never pairs with another release's CSS. A release reaches a new page load within about 5 minutes, which is the panel.js cache time. A page that is already open keeps its panel until it reloads. The panel's own stylesheet and fonts still apply when the host imports an older styles.css. A host with a Content Security Policy must allow https://workbench.embeddables.com in script-src, style-src, and font-src, or pass panelUrl={null}.

initWorkbench

import { initWorkbench } from '@embeddables/workbench'

const handle = initWorkbench({ enabled: false })

Returns { enabled, projectId, experiments }. enabled is true when options.enabled is true, the hostname (options.locationHost or window.location.hostname) is on *.embd.co, or the search string (options.locationSearch or window.location.search) has the exact query value workbench=true. This does not mount the panel.

Source

The package lives in packages/workbench/ of the embeddables-dashboard repo. Package rules are in AGENTS.md; behavior the props do not show is in docs/workbench.md.