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

viewport-debugger-ui

v1.0.2

Published

A lightweight utility for debugging viewport sizes and media queries in the browser console

Readme

npm install viewport-debugger-ui


## Basic Usage

```typescript
import { createViewportDebugger } from 'viewport-debugger-ui';

// Create a debugger instance with default options
const debugger = createViewportDebugger();

// Enable debugging (shows overlay)
debugger.enable();

// Disable debugging when done
debugger.disable();

Configuration

You can customize the debugger behavior by passing options:

const debugger = createViewportDebugger({
  updateInterval: 500,        // Update frequency in milliseconds (default: 1000)
  showMediaQueries: true,     // Show active media queries (default: true)
  compactMode: false          // Start in compact mode (default: false)
});

API Reference

createViewportDebugger(options?)

Creates a new viewport debugger instance.

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | updateInterval | number | 1000 | Frequency of viewport updates in milliseconds | | showMediaQueries | boolean | true | Whether to display active media queries | | compactMode | boolean | false | Enable compact display mode |

ViewportDebugger Methods

| Method | Description | |--------|-------------| | enable() | Starts the debugger and shows the overlay | | disable() | Stops the debugger and removes the overlay | | toggleCompactMode() | Toggles between compact and full display modes |

React Integration Example

import { useEffect, useState } from 'react';
import { createViewportDebugger, type ViewportDebugger } from 'viewport-debugger-ui';

function App() {
  const [debugger, setDebugger] = useState<ViewportDebugger | null>(null);

  useEffect(() => {
    const instance = createViewportDebugger({
      updateInterval: 500,
      showMediaQueries: true
    });

    setDebugger(instance);
    instance.enable();

    return () => instance.disable();
  }, []);

  return (
    <div>
      <h1>Your App Content</h1>
    </div>
  );
}

Next.js Integration Example

Here's how to integrate the viewport debugger with Next.js:

For Next.js App Router

// app/viewport-debugger.tsx
'use client'

import { useEffect } from 'react'
import { createViewportDebugger } from 'viewport-debugger-ui'

export function ViewportDebugger() {
  useEffect(() => {
    // Only run in development environment and browser
    if (process.env.NODE_ENV === 'development' && typeof window !== 'undefined') {
      const debugger = createViewportDebugger({
        updateInterval: 500,
        showMediaQueries: true
      })
      debugger.enable()
      
      return () => debugger.disable()
    }
  }, [])
  
  // This component doesn't render anything
  return null
}

Then import it in your root layout:

// app/layout.tsx
import { ViewportDebugger } from './viewport-debugger'

export default function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return (
    <html lang="en">
      <body>
        {children}
        <ViewportDebugger />
      </body>
    </html>
  )
}

For Next.js Pages Router

// components/ViewportDebugger.tsx
import { useEffect } from 'react'
import { createViewportDebugger } from 'viewport-debugger-ui'

export function ViewportDebugger() {
  useEffect(() => {
    // Only run in development environment and browser
    if (process.env.NODE_ENV === 'development' && typeof window !== 'undefined') {
      const debugger = createViewportDebugger({
        updateInterval: 500,
        showMediaQueries: true
      })
      debugger.enable()
      
      return () => debugger.disable()
    }
  }, [])
  
  // This component doesn't render anything
  return null
}

Then import it in your _app.tsx:

// pages/_app.tsx
import type { AppProps } from 'next/app'
import { ViewportDebugger } from '../components/ViewportDebugger'

export default function App({ Component, pageProps }: AppProps) {
  return (
    <>
      <Component {...pageProps} />
      <ViewportDebugger />
    </>
  )
}

Statamic Integration Example

Here's how to integrate the viewport debugger with Statamic:

  1. First, install the package in your Statamic project:
npm install viewport-debugger-ui
  1. Create a new JavaScript file (e.g., resources/js/viewport-debug.js):
import { createViewportDebugger } from 'viewport-debugger-ui';

// Only enable in development environment
if (process.env.NODE_ENV === 'development') {
  const debugger = createViewportDebugger({
    updateInterval: 500,
    showMediaQueries: true
  });
  debugger.enable();
}
  1. Add it to your Vite configuration (vite.config.js):
export default defineConfig({
  build: {
    input: [
      'resources/js/site.js',
      'resources/js/viewport-debug.js', // Add this line
      'resources/css/site.css',
    ],
  }
});
  1. Import it in your Antlers layout file (resources/views/layout.antlers.html):
<!DOCTYPE html>
<html lang="{{ site:short_locale }}">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ title ?? site:name }}</title>
    {{ vite src="resources/js/viewport-debug.js" }} <!-- Add this line -->
</head>
<body>
    {{ template_content }}
    {{ vite src="resources/js/site.js" }}
</body>
</html>

This setup will automatically enable the viewport debugger in development mode while keeping it disabled in production. The debugger overlay will appear in the top-right corner of your Statamic site, showing viewport dimensions and active media queries.

You can also conditionally enable it based on Statamic's environment variables:

if ({{ environment }} === 'local') {
    const debugger = createViewportDebugger();
    debugger.enable();
}