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/remark-sandpack

v1.0.0

Published

Author Sandpack examples in MDX

Readme

remark-sandpack

Use @lekoarts/remark-sandpack to more easily author Sandpack examples in your MDX. It parses individual code blocks and places them into Sandpack's files option. This way you don't have to write the JSX yourself.

[!NOTE] This package is a fork of thecuvii/remark-sandpack as the repository was put into read-only mode. @lekoarts/remark-sandpack is leaner, up-to-date, and maintained.

Installation

This package is ESM only.

npm install @lekoarts/remark-sandpack

Usage

Say your document index.mdx contains:

<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>

And the module index.mjs contains:

import remarkSandpack from '@lekoarts/remark-sandpack'
import { remark } from 'remark'
import remarkMdx from 'remark-mdx'
import { read } from 'to-vfile'

const file = await remark()
	.use(remarkMdx)
	.use(remarkSandpack)
	.process(await read('example.mdx'))

console.log(String(file))

Then running index.mjs yields:

<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}}}>
  ```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 individual code blocks are added to the files prop of the <Sandpack> component. Any other props will be passed through to the <Sandpack> component, e.g. in the example above the template="react" is kept in place.

Code blocks

You are required to add a name to each code block.

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

You can also add optional configuration for each code block (Sandpack's file format).

  • hidden
  • active
  • readOnly
  • showReadOnly

Add them after the filename like so:

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

API

This package exports no identifiers. The default export is remarkSandpack.

unified().use(remarkSandpack[, options])

Add support for transforming code blocks into files prop for <Sandpack> components.

Parameters

  • options (Options, optional) — configuration

Returns

Nothing (undefined).

Notes

Doesn't handle adding Sandpack to your app and into your MDX. Follow the Sandpack install instructions to add Sandpack. You'll need to pass/import that component into your MDX.

Options

Configuration (TypeScript type)

Fields

  • componentName (Array<string>, default: ['Sandpack']) — By default, @lekoarts/remark-sandpack looks for <Sandpack> occurences in the MDX. If you use a different name, adjust componentName. You can also pass in multiple names in case you have different Sandpack components.

Examples

Custom componentName

This example overrides the default componentName in order to use a different name in the MDX.

import remarkSandpack from '@lekoarts/remark-sandpack'
import { remark } from 'remark'
import remarkMdx from 'remark-mdx'
import { read } from 'to-vfile'

const file = await remark()
	.use(remarkMdx)
	.use(remarkSandpack, { componentName: ['Playground'] })
	.process(await read('example.mdx'))

console.log(String(file))
<Playground template="vanilla">

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

</Playground>

Astro

You can view a full end-to-end example inside examples/astro.