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

@rasamjs/react

v0.1.1

Published

React bindings for the rasam SVG editor.

Readme

@rasamjs/react

Use useActiveTool to observe and activate optional registered tools alongside the built-in tools. useTool retains its built-in types.

React bindings for @rasamjs/editor: a component that mounts the editor, and hooks that read its selection, history, layers, properties, commands and tool.

import { RasamEditor, useHistory, useProperty, useSelection } from '@rasamjs/react';

function Inspector() {
  const nodes = useSelection();
  const [fill, setFill] = useProperty('fill');
  const { canUndo, undoLabel } = useHistory();
  return (
    <aside>
      {nodes.length} selected, {canUndo ? `undo ${undoLabel}` : 'nothing to undo'}
      <input
        type="color"
        disabled={!nodes.length}
        value={typeof fill === 'string' ? fill : '#000000'}
        onChange={(event) => setFill(event.target.value, { mergeKey: 'fill' })}
      />
    </aside>
  );
}

export function App() {
  return (
    <RasamEditor options={{ autosave: { key: 'my-app' } }} style={{ height: 600 }}>
      <Inspector />
    </RasamEditor>
  );
}

Mounting

<RasamEditor> renders a host div and creates the Editor in an effect, so rendering never touches the DOM. Give the host a size with className or style; the editor document fills it. Children render after the host and receive the editor through context.

options are read once, when the editor is created. Change a section later with editor.configure(), or give the component a new key to create a fresh editor. onReady(editor) runs after creation, for example to register commands. A function it returns runs before the editor is destroyed; failures in either are reported through the editor's error event instead of thrown.

Unmounting destroys the editor, which saves pending autosave changes first. In StrictMode, React mounts, unmounts and mounts again: the first editor is destroyed and the second one stays, so the host always holds exactly one editor document.

Hooks

Every hook reads the nearest <RasamEditor>, or takes an editor as its last argument (null for none). Without an editor, before mounting and on the server, they return empty values: no selection, no history, no layers, the Select tool and undefined properties.

| Hook | Returns | | -------------------------- | ----------------------------------------------------------------- | | useEditor() | The Editor, or null | | useSelection() | The selected nodes | | useHistory() | canUndo, canRedo, counts and labels | | useLayers() | The layers rows, topmost first | | useProperty(key) | [value, write]; the value is mixed when the selection differs | | useProperties() | The shared Properties model | | useCommands() | Every command with its live enabled state and run() | | useCommand(id) | One command's state, or undefined | | useTool() | [tool, setTool] | | useEditorEvent(type, fn) | Subscribes fn to an editor event for the component's lifetime |

Hooks re-render only when their value changes: a pan or zoom doesn't re-render a selection panel. Values keep their identity until they change, so they work as effect dependencies. Hooks follow editor.load() and component reconfiguration, including a replaced layers model.

Command state follows selection, history, tool, gesture and scene changes, and updates immediately on registry registration, override, removal and rebinding. Call editor.commands.invalidate() when application-owned enabled state changes. onReady remains useful for registering commands when an editor is created.

RasamEditorContext is exported for apps that create the Editor themselves and want the hooks: wrap the tree in <RasamEditorContext.Provider value={editor}>.

Requirements

React 18.3 or 19, and @rasamjs/editor with its seven rasam peers. The package has no runtime dependencies. See API.md for the full reference and apps/react-example for a complete Vite app.