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

@sanity/visual-editing-standalone

v2.0.1

Published

Self-contained ESM build of Sanity Visual Editing for non-React applications

Readme

@sanity/visual-editing-standalone

Self-contained, ESM-only Visual Editing for applications that do not otherwise use React.

The entire API is a single entry point:

import {createDataAttribute, enableVisualEditing} from '@sanity/visual-editing-standalone'

All runtime code—including the internal React renderer, React DOM, styled-components, and Sanity UI—is compiled into package-internal ESM chunks. Installing it adds no production or peer dependencies, and the exact bundled versions are listed in the inlinedDependencies field of package.json.

The overlays' static stylesheet ships as the ./styles.css export — named after the @sanity/ui@4 subpath it repackages — and must be imported explicitly, as shown in Import the stylesheet. The published JS never references the stylesheet itself, so the package loads in every ESM runtime — bundlers, Node, esm.sh, import maps — without CSS-handling support.

When to use this package

Use this package with Vue, Nuxt, Svelte, Astro, vanilla JavaScript, or another ESM-native environment where installing and bundling the React dependency graph is undesirable.

React applications should use @sanity/visual-editing instead. This package embeds its own React runtime, so using it in a React application would ship a second copy.

The word "standalone" describes this package's self-contained distribution. It is unrelated to the standalone value reported by Visual Editing environment APIs.

Install

npm install @sanity/visual-editing-standalone

No React packages need to be installed alongside it.

Import the stylesheet

Import the overlays' static styles once, wherever Visual Editing is enabled:

import '@sanity/visual-editing-standalone/styles.css'

Bundlers handle the import like any other stylesheet. Without a bundler, add a <link> tag instead, as in the esm.sh example below.

Skipping the stylesheet does not break the overlays, but the loading-spinner animation, screen-reader-only hiding, and label ellipsis rules go missing.

Enable Visual Editing

Only load Visual Editing in the browser while draft or preview mode is active:

import '@sanity/visual-editing-standalone/styles.css'
import {enableVisualEditing} from '@sanity/visual-editing-standalone'

const disableVisualEditing = enableVisualEditing({
  history: {
    subscribe: (navigate) => {
      const onPopState = () => {
        navigate({type: 'pop', url: location.href})
      }

      addEventListener('popstate', onPopState)
      return () => removeEventListener('popstate', onPopState)
    },
    update: (update) => {
      if (update.type === 'push') history.pushState(null, '', update.url)
      if (update.type === 'replace') history.replaceState(null, '', update.url)
      if (update.type === 'pop') history.back()
    },
  },
})

// Call this when preview mode is disabled or the page is torn down.
disableVisualEditing()

The overlay renderer stays in a separate lazy chunk that only loads when enableVisualEditing() is called. Applications that only import createDataAttribute never load it, and since the JS is side-effect free any bundler can tree-shake the unused enableVisualEditing export away entirely.

The standalone options are framework-neutral. React-based custom overlay components and plugins remain available from @sanity/visual-editing.

Create data attributes

Use createDataAttribute for values that cannot carry stega encoding, such as images, numbers, and booleans:

import {createDataAttribute} from '@sanity/visual-editing-standalone'

const dataSanity = createDataAttribute({
  baseUrl: 'https://example.sanity.studio',
  id: 'post-1',
  type: 'post',
  path: 'mainImage',
}).toString()

Load from esm.sh

The package can be loaded directly as a browser module — add the stylesheet with a <link> tag:

<link rel="stylesheet" href="https://esm.sh/@sanity/visual-editing-standalone@2/styles.css" />
<script type="module">
  import {
    createDataAttribute,
    enableVisualEditing,
  } from 'https://esm.sh/@sanity/visual-editing-standalone@2'

  document.querySelector('h1').dataset.sanity = createDataAttribute({
    baseUrl: 'https://example.sanity.studio',
    id: 'post-1',
    type: 'post',
    path: 'title',
  }).toString()

  enableVisualEditing()
</script>

Pin an exact package version in production when deterministic CDN output is required.