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

@kazweda/scratchblocks-astro

v0.4.0

Published

Unofficial Scratchblocks renderer Astro component.

Readme

scratchblocks-astro

Unofficial Scratchblocks renderer Astro component.

No UI framework is required: the component is a plain .astro file, so you do not need @astrojs/react or React.

Install

npm install @kazweda/scratchblocks-astro
pnpm add @kazweda/scratchblocks-astro
yarn add @kazweda/scratchblocks-astro

Usage (Astro MDX)

import { ScratchblocksRenderer } from '@kazweda/scratchblocks-astro';

<ScratchblocksRenderer
  code={`when flag clicked
move (10) steps`}
/>

Props

| Prop | Type | Default | Description | | --- | --- | --- | --- | | code | string | (required) | Scratchblocks syntax to render. | | style | 'scratch2' \| 'scratch3' | 'scratch3' | Block visual style. | | languages | string[] | undefined | Language codes passed through to scratchblocks.parse/render (e.g. ['en']). Load extra languages with scratchblocks.loadLanguages beforehand. | | class, other HTML attributes | — | — | Passed through to the root <div>. Note: the style HTML attribute is not passed through, since style is reserved for the block style option above. |

Development

See DEVELOPMENT.md.

How it works

The component renders an empty <div> with the props stored in data-* attributes, plus a small script that loads scratchblocks in the browser and replaces each <div> with the rendered SVG. If parsing fails, the code is shown as-is in a <pre class="blocks">.

It works with several blocks on one page and with View Transitions (<ClientRouter />), where it renders again on astro:page-load.

Migrating from 0.3.x

0.4.0 replaces the React component with an Astro component. To upgrade:

  1. Remove client:load (or client:idle) from <ScratchblocksRenderer>. Astro components do not take client:* directives; if left in, Astro logs a warning for each use.
  2. Rename className to class.
  3. The vite.optimizeDeps.include and vite.ssr.noExternal entries for this package in astro.config.mjs are no longer needed.
  4. If nothing else on your site uses React, you can remove @astrojs/react, react and react-dom.

License

MIT. This package depends on scratchblocks, which is also MIT licensed. Not affiliated with or endorsed by the scratchblocks project.