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

msw-ui-widget

v0.1.4

Published

React widget for managing MSW mocks in real-time during development

Readme

MSW UI Widget

React widget for managing MSW (Mock Service Worker) mocks in real-time during development. Automatically discovers endpoints from OpenAPI 3.0 specification and allows you to override responses, manage response queues, and monitor API calls.

Features

  • 🎯 OpenAPI Integration: Automatically parses OpenAPI 3.0 specs and discovers all endpoints
  • 🔄 Real-time Mocking: Override MSW handlers at runtime without restarting your app
  • 📊 Response Queues: Set up multiple responses for the same endpoint that cycle through
  • 📈 Call Monitoring: Track which endpoints were called and how many times
  • 🎨 Developer-Friendly UI: Clean, intuitive interface with floating button and panel
  • 🔍 Search & Filter: Quickly find endpoints by path or HTTP method
  • 📝 Call History: View detailed history of API calls with timestamps

Installation

npm install msw-ui-widget

Or clone this repository and use the source code directly.

Requirements

  • React 18+
  • MSW 2.0+
  • OpenAPI 3.0 specification file (JSON or YAML)

Note: Tailwind CSS is bundled with the widget - you don't need to configure it in your project!

Usage

Basic Setup

import { MswUiWidget } from 'msw-ui-widget';
// Styles are automatically injected - no need to import CSS!
import { setupWorker } from 'msw/browser';

// Your MSW worker
const worker = setupWorker(...handlers);

// Start MSW
await worker.start();

function App() {
  return (
    <>
      {/* Your app components */}
      <YourApp />

      {/* MSW Widget - renders as a floating button */}
      <MswUiWidget
        worker={worker}
        openapiUrl="/path/to/openapi.json"
        visible={true}
      />
    </>
  );
}

Props

| Prop | Type | Required | Description | | ------------ | ------------ | -------- | ------------------------------------------------ | | worker | MSW Worker | Yes | MSW worker instance | | openapiUrl | string | Yes | Path to OpenAPI 3.0 specification (JSON or YAML) | | visible | boolean | No | Control widget visibility (default: true) |

Example with Vite

// main.tsx
import React from 'react';
import ReactDOM from 'react-dom/client';
import { MswUiWidget } from 'msw-ui-widget';
// Styles are automatically injected - no need to import CSS!
import { setupWorker } from 'msw/browser';
import { handlers } from './mocks/handlers';
import App from './App';

const worker = setupWorker(...handlers);

async function startApp() {
  await worker.start({
    onUnhandledRequest: 'bypass',
  });

  ReactDOM.createRoot(document.getElementById('root')!).render(
    <React.StrictMode>
      <App />
      <MswUiWidget
        worker={worker}
        openapiUrl="/api/openapi.json"
        visible={process.env.NODE_ENV === 'development'}
      />
    </React.StrictMode>
  );
}

startApp();

How It Works

  1. OpenAPI Parsing: Widget loads and parses your OpenAPI 3.0 specification
  2. Endpoint Discovery: All endpoints are extracted and displayed in the widget panel
  3. Mock Management: Click on any endpoint to create or edit a mock response
  4. Runtime Override: Mocks are injected into MSW at runtime, taking precedence over existing handlers
  5. Call Tracking: Widget monitors all API calls and displays call counts and history

Features in Detail

Response Queues

Create multiple responses for the same endpoint. Responses will cycle through in order:

  1. Click on an endpoint
  2. Enable "Use response queue"
  3. Add multiple responses
  4. Each call will return the next response in the queue

Call Monitoring

  • Visual Indicators: Endpoints flash when called
  • Call Counters: See how many times each endpoint was called
  • Call History: Open the history sidebar to see detailed call logs

Search & Filter

  • Search: Type in the search box to filter endpoints by path
  • Method Filter: Click on HTTP method buttons to filter by method (GET, POST, etc.)

Limitations

  • Currently supports OpenAPI 3.0 only (not 3.1 or Swagger 2.0)
  • MSW runtime handler updates may have limitations depending on MSW version
  • Widget is designed for desktop use (not responsive in MVP)
  • State resets on page reload (no persistence in MVP)

Development

# Install dependencies
npm install

# Build
npm run build

# Type check
npm run type-check

Project Structure

src/
├── components/       # React components
├── hooks/           # Custom React hooks
├── store/           # Zustand state management
├── utils/           # Utilities (parsers, managers)
└── styles/          # CSS styles

Contributing

This is an MVP implementation. Future improvements may include:

  • Persistence of mock configurations
  • Export/import mock configurations
  • Response presets
  • Network delay simulation
  • More detailed call history
  • Support for OpenAPI 3.1 and Swagger 2.0

License

MIT