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

mobx-visualizer

v1.1.0

Published

Visualizer of MobX events using sequence diagrams

Readme

MobX Visualizer

A powerful tool for visualizing MobX events as sequence diagrams, helping developers debug and understand state management flows in their applications.

Features

  • Tracks MobX events (actions, updates, etc.) and generates sequence diagrams using Mermaid.js.
  • Provides a debug mode with detailed console logging.
  • Automatically adds a "Download Diagram" button to your app in debug mode.
  • Customizable via options (e.g., exclude specific stores or actions).
  • Exports SVG diagrams for easy sharing and analysis.

Installation

Install the package via npm:

npm install mobx-visualizer --save-dev

Usage

Basic Setup

Import and initialize the visualizer in your application:

import React from "react";
import mobxVisualizer from "mobx-visualizer";

mobxVisualizer({ debug: true });

function App() {
  return (
    <div>
      <h1>My App</h1>
      {/* Your app content */}
    </div>
  );
}

export default App;

When debug: true is set, a "Download Mobx Sequence Diagram" button will appear in the bottom-right corner of your app. Clicking it generates and downloads an SVG of the recorded MobX events (Make sure to allow your localhost to download files in your browser's security settings). It will also console log every observed change to the MobX state.

Advanced Configuration

Customize the visualizer with options:

import mobxVisualizer from "mobx-visualizer";

const visualizer = mobxVisualizer({
  debug: true, // Enable debug logging and download button
  excludeStores: ["TempStore"], // Ignore events from specific stores
  excludeActions: ["initialize"], // Ignore specific action names
  eventHook: (event) => console.log("New event:", event), // Custom event handler
});

// Generate SVG manually if needed
visualizer.renderSVG().then((url) => console.log("Diagram URL:", url));

React Integration Example

Integrate with a MobX-powered React app:

import React from "react";
import { RootStore } from "./stores/RootStore";
import { StoreProvider } from "./stores/StoreContext";
import mobxVisualizer from "mobx-visualizer";

const visualizer = mobxVisualizer({ debug: true });
const rootStore = new RootStore();

function App() {
  return (
    <StoreProvider store={rootStore}>
      <div className="min-h-screen bg-gray-100">
        <h1>Todo App</h1>
        {/* Your components */}
      </div>
    </StoreProvider>
  );
}

export default App;

API

mobxVisualizer(options)

Creates a new visualizer instance.

Options

| Property | Type | Description | Default | |------------------|-----------------------------|--------------------------------------------------|-------------| | debug | boolean | Enable debug logging and download button | false | | excludeStores | string[] | Stores to exclude from tracking | [] | | excludeActions | string[] | Actions to exclude from tracking | [] | | eventHook | (event: VisualizerEvent) => void | Callback for each tracked event | undefined |

Methods

  • getEvents(): VisualizerEvent[] - Returns all tracked events.
  • clearEvents(): void - Clears the event history.
  • renderSVG(): Promise<string> - Generates an SVG diagram and returns its Blob URL.

VisualizerEvent

Represents a tracked MobX event: | Property | Type | Description | |-------------|----------|---------------------------------| | event | any | Raw MobX event data | | id | string | Unique event identifier | | timestamp | number | Event timestamp (milliseconds) | | type | string | Event type (e.g., "action") | | name | string | Event name | | object | string | Source object/store name |

How It Works

  1. Event Tracking: Uses MobX’s spy to intercept events (actions, updates, etc.).
  2. Filtering: Applies filters based on options to exclude unwanted events.
  3. Diagram Generation: Converts events into a Mermaid sequence diagram.
  4. Rendering: In debug mode, adds a button to download the SVG; otherwise, provides renderSVG() for manual generation.

Example Diagram

Here’s what a generated sequence diagram might look like:

sequenceDiagram
  participant RootStore
  RootStore ->> RootStore: [12:00:00] addTodo("Buy milk")
  RootStore ->> RootStore: [12:00:01] toggleTodo(1)

Limitations

  • Event Types: Currently tracks a subset of MobX events (excludes reactions, adds, removes, deletes, and splices by default).
  • Browser Only: The download button feature requires a DOM environment.

Contributing

  1. Fork the repository.
  2. Create a feature branch (git checkout -b feature/new-feature).
  3. Commit your changes (git commit -m "Add new feature").
  4. Push to the branch (git push origin feature/new-feature).
  5. Open a Pull Request.

Development Setup

Clone and install dependencies:

git clone https://github.com/amans199/mobx-visualizer.git
cd mobx-visualizer
npm install

Build the package:

npm run build

License

MIT License © 2025 [Your Name/Organization]


This documentation covers installation, usage, API details, and contribution guidelines. You can customize the repository URL, author name, and license as needed when adding it to your GitHub project! Let me know if you’d like to tweak anything further.