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 ๐Ÿ™

ยฉ 2025 โ€“ย Pkg Stats / Ryan Hefner

@smoothglue/dev-console

v1.0.1

Published

A powerful ๐Ÿ’ช, draggable ๐Ÿ–ฑ๏ธ developer console for React applications โš›๏ธ. This tool provides an in-app overlay to inspect network traffic ๐Ÿšฆ, view console logs ๐Ÿ“œ, and execute custom commands โšก without needing to open the browser's developer tools ๐Ÿ› ๏ธ.

Readme

๐Ÿ› ๏ธ Smoothglue Dev Console

A powerful ๐Ÿ’ช, draggable ๐Ÿ–ฑ๏ธ developer console for React applications โš›๏ธ. This tool provides an in-app overlay to inspect network traffic ๐Ÿšฆ, view console logs ๐Ÿ“œ, and execute custom commands โšก without needing to open the browser's developer tools ๐Ÿ› ๏ธ.

Table of Contents ๐Ÿ“‘


โœจ Features

  • ๐ŸŒ Network Console: Intercept and inspect fetch requests and responses using a dedicated Service Worker.
    • View JSON {} and HTML <html> responses directly in the UI.
    • Filter by content type (JSON , JS , Image, CSS, HTML).
    • Monitor request status and timing.
  • ๐Ÿ“ Log Console: Captures and displays standard console logs (log, debug, warn, info , error).
    • Preserves logs within the app context.
    • Search and filter logs.
  • โฑ๏ธ Performance Monitor: Granularly track the execution time of specific functions and components.
    • View real-time statistics (Min, Max, Average) for your operations.
    • Visualize execution history.
    • Supports synchronous functions, promises, and React component renders.
  • ๐Ÿš€ System Health: Monitor real-time application and system performance.
    • System: Track Frames Per Second (FPS), CPU concurrency, and Memory usage.
    • Network: Inspect connection type (4g, wifi), downlink speed, and RTT.
    • Load: Analyze critical loading timings including FCP, TTFB, and DOM load times.
  • โŒจ๏ธ Command Console: Register and execute custom commands directly from the UI.
    • Trigger specific app states or utility functions.
  • ๐Ÿ–ฑ๏ธ Draggable & Resizable: Built on react-rnd, the console floats over your app and can be moved or resized to fit your workflow.
  • ๐ŸŽจ Theming: Comes with a dark mode developer theme (devConsoleTheme) using Material UI.

๐Ÿš€ Getting Started

๐Ÿ“ฆ Installation

Install the package using npm or yarn:

npm install smoothglue-dev-console

Copy the service worker ๐Ÿ‘ท

This package uses a service worker to gather console and network logs. This service worker must be added to your applications' public folder so that it can be accessed by the browser.

The file can be copied manually by using the following command after installation:

cp node_modules/smoothglue-dev-console/dist/devConsoleServiceWorker.js public/

Alternatively, you can run the command npx copy-dev-console-sw after installation to copy the file to your public folder.

Peer Dependencies ๐Ÿค

This library relies on several peer dependencies that must be installed in your project ๐Ÿ”—. It supports both React 18 and React 19.

Ensure you have the core React and Material UI packages installed:

npm install react react-dom @mui/material @mui/icons-material

This library also utilizes MUI components. You must install the following packages:

npm install @mui/x-data-grid @mui/x-date-pickers

Or their pro versions:

npm install @mui/x-data-grid-pro @mui/x-date-pickers-pro

Note: @mui/x-data-grid-pro and @mui/x-date-pickers-pro are commercial packages that require a valid license key from MUI.

Usage ๐ŸŽฎ

DevConsoleProvider

To use the console, wrap your application with the DevConsoleProvider. This context handles the state for logs, network traffic, and visibility. You can also inject custom panes (tabs) for app-specific tools, such as feature flags.

<ThemeProvider theme={theme}>
  <DevConsoleProvider
    customPanes={[
      {
        label: "Feature Flags ๐Ÿšฉ",
        component: () => <DevFlagsConsole />,
      },
    ]}
  >
    <App />
  </DevConsoleProvider>
</ThemeProvider>

DevConsoleProvider Props โš™๏ธ

| Prop | Type | Default | Description | | :--------------------------------- | :----------------- | :----------------- | :------------------------------------------------------------------------------------------------------------------------------------------- | | children | ReactNode | Required | The content of your application that will have access to the DevConsole context. | | customPanes | DevConsolePane[] | [] | An array of custom tabs to add to the console. Each object must contain a label (string) and a component (function returning ReactNode). | | hotkeys | string | "ctrl+shift+d+c" | The keyboard shortcut string used to toggle the console visibility. Pass NONE to prevent the use of hotkeys to activate the console. | | maxNetworkLogSize | number | 500 | The maximum number of network requests to keep in the log history. Older entries are removed when the limit is reached. | | performanceMonitoringEnabled | boolean | true | Enables or disables the collection of performance metrics for the Performance Monitor tab. | | maxPerformanceHistory | number | 10 | The number of historical duration entries to keep for each source in the Performance Monitor. Used to calculate Min/Max/Avg stats. | | disabledConsoles | string[] | [] | An array of standard panels to disable/hide. Options: 'logs', 'network', 'system', 'performance'. | | theme | Theme | devConsoleTheme | The Material UI theme to use for the console styles. | | zIndex | number | 10,000 | The z-index CSS property for the console overlay. |

Recipes ๐Ÿ‘ฉโ€๐Ÿณ

Using a Dynamic Shortcut Key Combination

A dynamic hotkey combination can be provided as seen in this example. This example also disables hotkey activation until a hotkey combination is provided.

export const App=()=>{

  // wrap in other providers
    <DevConsoleWrapper>
      <App/>
    </DevConsoleWrapper>
}

export const DevConsoleWrapper =(children)=>{

    const hotkeys = getHotKeys() // a function that provides either a falsy value of a hotkey combination

    <DevConsoleProvider
      hotkeys={hotKeys ?? 'NONE'} // pass NONE to deactivate hotkeys until the hotkey state has a valid value
      customPanes={[
        {
          label: "Feature Flags ๐Ÿšฉ",
          component: () => <DevFlagsConsole />,
        },
      ]}
    >
      {children}
    </DevConsoleProvider>

}

useDevConsole Hook ๐Ÿช

The useDevConsole hook allows you to access the console state and controls from anywhere within the provider.

import { useDevConsole } from "smoothglue-dev-console";

const Header = () => {
  const { isVisible, setEnabled } = useDevConsole();

  return <button onClick={() => setEnabled(!isVisible)}>Toggle Console</button>;
};

Adding Custom Commands โšก

You can register commands that appear in the Command Console tab โŒจ๏ธ.

import { useDevConsole } from "smoothglue-dev-console";
import { useEffect } from "react";

const MyComponent = () => {
  const { registerCommand } = useDevConsole();

  useEffect(() => {
    // ๐Ÿ”” Register a new command
    const unregister = registerCommand({
      command: "clear-cache",
      description: "Clears local storage and reloads โ™ป๏ธ",
      callback: () => {
        localStorage.clear();
        window.location.reload();
      },
    });

    return unregister;
  }, []);

  return <div>App Content</div>;
};

Performance Monitoring Utilities โฑ๏ธ

The Dev Console provides several utilities to help you measure the execution time of functions and components. These metrics appear in the Performance tab.

measureSync & measurePromise

Wrap your functions to automatically log their duration.

import { measureSync, measurePromise } from "smoothglue-dev-console";

// Measure a synchronous function
const heavyCalculation = () => {
  measureSync("Data Processing", () => {
    // ... complex logic ...
  });
};

// Measure an asynchronous function
const fetchData = async () => {
  const result = await measurePromise("API Fetch", async () => {
    const response = await fetch("/api/data");
    return response.json();
  });
};

usePerformanceLogger

A hook for measuring operations within a component manually.

import { usePerformanceLogger } from "smoothglue-dev-console";

const DataGrid = () => {
  const { start, end } = usePerformanceLogger("DataGrid");

  const processRow = () => {
    start("Process Row");
    // ... logic ...
    end("Process Row");
  };

  return <button onClick={processRow}>Process</button>;
};

PerformanceProfiler

A component wrapper that logs the render duration of its children using the React Profiler.

import { PerformanceProfiler } from "smoothglue-dev-console";

const Dashboard = () => (
  <PerformanceProfiler id="DashboardWidget">
    <ComplexWidget />
  </PerformanceProfiler>
);

Note: If you are using libraries that rely on React Context (like resium for Cesium maps), wrapping them directly with PerformanceProfiler may break context propagation if your package dependencies are not perfectly aligned. In those cases, consider passing the necessary context (like the viewer instance) manually as props or using usePerformanceLogger within the component instead.

logDev Utility ๐Ÿ› ๏ธ

The logDev function is a helper utility that allows you to log messages directly to the Log Console tab with a specific "dev" type. These logs appear with distinct styling โœจ.

import { logDev } from "smoothglue-dev-console";

const performAction = () => {
  // Log a specific development message
  logDev("Action triggered successfully");
};

Capturing Logs from Workers ๐Ÿ‘ท

The Dev Console Service Worker can automatically intercept and display logs generated from Web Workers or Shared Workers.

To enable this:

  1. Import and enable logging in your worker: You must import enableWorkerLogging from the package and call it at the top of your worker script.

    import { enableWorkerLogging } from "@smoothglue/dev-console";
    
    enableWorkerLogging();
  2. Scope: Ensure your worker is running within the scope of the devConsoleServiceWorker (usually the root /).

  3. Log: Use standard console methods (console.log, console.warn, console.error) within your worker script.

These logs will be forwarded to the Log Console and appear alongside your main thread logs.

๐Ÿ“š Running Storybook

This project uses Storybook to develop and test UI components in isolation.

  1. Install dependencies:

    npm install
  2. Start the Storybook server:

    npm run storybook
  3. Open your browser: Navigate to http://localhost:6006 to view the DevConsole stories.

Contributing ๐Ÿคฒ

๐Ÿ“‚ Project Structure

  • src/lib/DevConsole: The main container component.
  • src/lib/networkConsole: Components and logic for the network logger.
  • src/lib/logEntries: Components for the console log viewer.
  • src/lib/commandConsole: The autocomplete input for executing commands.
  • src/lib/performanceMonitoringConsole: Logic for measuring execution times and the UI for displaying them.
  • src/devConsoleServiceWorker.ts: The service worker script for intercepting fetch requests.

Available Scripts ๐Ÿ“œ

In the project directory, you can run:

  • npm run dev: Starts the Vite development server โšก.
  • npm run build: Runs TypeScript type checking (tsc) and builds the library for production using Vite.
  • npm test: Runs the test suite using Vitest ๐Ÿงช.
  • npm run lint: Runs ESLint to analyze the code for quality issues ๐Ÿงน.
  • npm run tsc: Runs Typescript checking ๐Ÿ”.
  • npm run storybook: Starts the Storybook development server at http://localhost:6006.
  • npm run build-storybook: Builds the static Storybook documentation for deployment.