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

abc-hx

v0.0.2

Published

hooks

Readme

abc-hx

React hooks package for common UI utilities in the ABC system. This package provides reusable hooks for debouncing, responsive design, theme management, and screen resizing.

📦 Installation

pnpm add abc-hx

🚀 Key Features

1. Debouncing

  • Optimize performance by limiting update rates
  • Support for both number and string values
  • Configurable delay timing

2. Responsive Design

  • Mobile detection with customizable breakpoints
  • Screen resize handling with automatic reload
  • Real-time responsive state management

3. Theme Management

  • Light, dark, and system theme support
  • Automatic theme persistence in localStorage
  • CSS class management for theme switching

4. Screen Resize

  • Monitor screen size changes
  • Automatic page reload on breakpoint changes
  • Configurable mobile breakpoint

📚 API Reference

useDebounce(value, delay)

Returns a debounced version of the input value that updates after a specified delay.

import { useDebounce } from "abc-hx";

const debouncedValue = useDebounce(searchTerm, 500);

Parameters:

  • value: number | string - The value to debounce
  • delay: number - The debounce delay in milliseconds

Returns: number | string - The debounced value

Example:

import { useDebounce } from "abc-hx";

function SearchComponent() {
  const [searchTerm, setSearchTerm] = useState("");
  const debouncedSearchTerm = useDebounce(searchTerm, 500);

  useEffect(() => {
    // This effect will only run when debouncedSearchTerm changes
    // after 500ms of no changes to searchTerm
    performSearch(debouncedSearchTerm);
  }, [debouncedSearchTerm]);

  return (
    <input
      value={searchTerm}
      onChange={(e) => setSearchTerm(e.target.value)}
      placeholder="Search..."
    />
  );
}

useIsMobile()

Detects if the current screen size is mobile (≤768px).

import { useIsMobile } from "abc-hx";

const isMobile = useIsMobile();

Returns: boolean - True if screen width is ≤768px

Example:

import { useIsMobile } from "abc-hx";

function ResponsiveComponent() {
  const isMobile = useIsMobile();

  return (
    <div>
      {isMobile ? (
        <MobileLayout />
      ) : (
        <DesktopLayout />
      )}
    </div>
  );
}

useScreenResize()

Monitors screen size changes and automatically reloads the page when switching between mobile and desktop breakpoints.

import { useScreenResize } from "abc-hx";

useScreenResize();

Breakpoint: 414px (mobile breakpoint)

Example:

import { useScreenResize } from "abc-hx";

function App() {
  useScreenResize(); // Automatically reloads on breakpoint change

  return (
    <div>
      {/* Your app content */}
    </div>
  );
}

useTheme()

Manages theme state with support for light, dark, and system themes.

import { useTheme } from "abc-hx";

const { theme, toggleTheme } = useTheme();

Returns: { theme: string, toggleTheme: (theme: ThemeMode) => void }

ThemeMode: "light" | "dark" | "system"

Example:

import { useTheme } from "abc-hx";

function ThemeToggle() {
  const { theme, toggleTheme } = useTheme();

  return (
    <div>
      <button onClick={() => toggleTheme("light")}>
        Light
      </button>
      <button onClick={() => toggleTheme("dark")}>
        Dark
      </button>
      <button onClick={() => toggleTheme("system")}>
        System
      </button>
      <p>Current theme: {theme}</p>
    </div>
  );
}

🔧 Usage Examples

Complete Example with Multiple Hooks

import { useDebounce, useIsMobile, useTheme } from "abc-hx";

function AdvancedComponent() {
  const [searchTerm, setSearchTerm] = useState("");
  const debouncedSearchTerm = useDebounce(searchTerm, 300);
  const isMobile = useIsMobile();
  const { theme, toggleTheme } = useTheme();

  useEffect(() => {
    // Perform search with debounced term
    if (debouncedSearchTerm) {
      performSearch(debouncedSearchTerm);
    }
  }, [debouncedSearchTerm]);

  return (
    <div className={`app ${theme}`}>
      <div className="header">
        <input
          value={searchTerm}
          onChange={(e) => setSearchTerm(e.target.value)}
          placeholder="Search..."
          className={isMobile ? "mobile-input" : "desktop-input"}
        />
        <button onClick={() => toggleTheme(theme === "dark" ? "light" : "dark")}>
          Toggle Theme
        </button>
      </div>

      <div className={isMobile ? "mobile-content" : "desktop-content"}>
        {/* Responsive content */}
      </div>
    </div>
  );
}

Theme Management with CSS

/* Your CSS file */
.app.light {
  --bg-color: #ffffff;
  --text-color: #000000;
}

.app.dark {
  --bg-color: #1a1a1a;
  --text-color: #ffffff;
}

.app {
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: all 0.3s ease;
}

📋 Type Definitions

// useDebounce
function useDebounce(value: number | string, delay: number): number | string;

// useIsMobile
function useIsMobile(): boolean;

// useScreenResize
function useScreenResize(): void;

// useTheme
type ThemeMode = "light" | "dark" | "system";

interface UseThemeReturn {
  theme: string;
  toggleTheme: (theme: ThemeMode) => void;
}

function useTheme(): UseThemeReturn;

🔧 Development

# Build package
pnpm build

# Development mode with watch
pnpm dev

# Type checking
pnpm check-types

# Lint
pnpm lint

# Clean dist
pnpm clean

📦 Dependencies

Development Dependencies

  • @testing-library/jest-dom - Jest DOM matchers
  • @repo/eslint-config - ESLint configuration
  • @testing-library/react - React testing utilities
  • @types/jest - Jest types
  • @types/node - Node.js types
  • tsup - TypeScript bundler
  • typescript - TypeScript compiler

🧪 Testing

All hooks include comprehensive test coverage:

# Run tests
pnpm test

# Run tests with coverage
pnpm test:coverage

📄 License

ISC