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

@lekoarts/satteri-sandpack

v1.0.0

Published

Author Sandpack examples in MDX with Sätteri

Readme

sätteri-sandpack

Author Sandpack files as fenced code blocks in MDX compiled by Sätteri.

@lekoarts/satteri-sandpack is a native, synchronous Sätteri MDAST plugin. It's a port of my remark-sandpack package.

Installation

This package is ESM only and requires Node.js 22 or newer. It supports Sätteri >=0.10.5.

npm install @lekoarts/satteri-sandpack satteri

Install and render a Sandpack component separately, such as @codesandbox/sandpack-react. This plugin only creates the component's files prop during MDX compilation.

Usage

Given this MDX:

<Sandpack template="react">

```js name=App.js active
import { NAME } from './constants.js'

export default function App() {
  return <h1>Hello {NAME}</h1>
}
```

```js name=constants.js readOnly
export const NAME = 'World'
```

</Sandpack>

The plugin appends a files expression equivalent to:

<Sandpack
	template="react"
	files={{
		'App.js': {
			code: 'import { NAME } from \'./constants.js\'\n\nexport default function App() {\n  return <h1>Hello {NAME}</h1>\n}',
			active: true,
		},
		'constants.js': {
			code: 'export const NAME = \'World\'',
			readOnly: true,
		},
	}}
>
	{/* Existing MDX children remain here. */}
</Sandpack>

Existing attributes and children are preserved. If the component already has a files attribute, the generated attribute is appended after it. If multiple blocks use the same filename, the final block wins.

Direct mdxToJs integration

import satteriSandpack from '@lekoarts/satteri-sandpack'
import { mdxToJs } from 'satteri'

const result = mdxToJs(source, {
	mdastPlugins: [satteriSandpack()],
})

console.log(result.code)

The plugin is synchronous, so adding it does not make mdxToJs return a Promise.

Vite integration

Use the plugin through vite-plugin-satteri:

import satteriSandpack from '@lekoarts/satteri-sandpack'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
import satteri from 'vite-plugin-satteri'

export default defineConfig({
	plugins: [
		react(),
		satteri({
			mdastPlugins: [satteriSandpack({ componentName: ['Playground'] })],
		}),
	],
})

A complete Vite + React application is available in examples/vite-react.

Code-block metadata

Every fenced code block inside a matching component requires non-empty metadata containing name=...:

```js name=filename.js active
console.log('Hello World')
```

The filename may be followed by any of these boolean Sandpack file flags:

  • active: forwards active: true
  • hidden: forwards hidden: true
  • readOnly: forwards readOnly: true
  • showReadOnly: forwards showReadOnly: true, commonly alongside readOnly

Flags may appear in any order and are included only when present. Code blocks nested more deeply inside the matching MDX flow component are collected recursively.

Invalid metadata throws during compilation:

  • missing metadata: code blocks cannot have empty metadata
  • missing or empty name=...: code blocks must have a name attribute
  • unknown tokens: only active, hidden, readOnly, and showReadOnly are accepted after the filename

Configuration

The default component name is Sandpack:

satteriSandpack()

Use componentName for a custom component:

satteriSandpack({ componentName: ['Playground'] })

Pass multiple names when the same document uses more than one wrapper:

satteriSandpack({
	componentName: ['Playground', 'MinimalPlayground'],
})

Only matching MDX flow elements are transformed. Nameless and unmatched elements are left unchanged.

API

The package has one runtime export: the default satteriSandpack factory. It also exports its configuration type as Options.

satteriSandpack(options?)

Returns a named Sätteri MdastPluginDefinition.

Options

interface Options {
	componentName?: Array<string>
}