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

garuda-hooks

v1.3.0

Published

A zero-dependency React/NextJS hooks: TypeScript-first (strict, no any), SSR-safe browser API usage, consistent tuple/object returns, ESM+CJS output with generated types, Vitest + React Testing Library coverage, and tree-shakeable per-hook entry points.

Downloads

496

Readme

garuda-hooks

A production-ready, TypeScript-first collection of React and Next.js hooks. Built with SSR safety, strict typing, and consistent APIs in mind.

Author

Francis Tin-ao

Features

  • Zero-dependency hooks for React and NextJS
  • TypeScript-first with strict mode, no any
  • SSR-safe defaults for browser APIs
  • Consistent return patterns (tuple or object) across hooks
  • ESM + CJS output with generated types
  • Tested with Vitest + React Testing Library
  • Tree-shakeable per-hook entry points

Installation

npm install garuda-hooks
# or
yarn add garuda-hooks
# or
pnpm add garuda-hooks

Quick Start

import { useLocalStorage } from 'garuda-hooks'

function Example() {
  const { value, setValue, remove } = useLocalStorage('key', 'hello')
  return (
    <div>
      <p>{value}</p>
      <button onClick={() => setValue('world')}>Set</button>
      <button onClick={remove}>Remove</button>
    </div>
  )
}

Hook Categories (Planned)

  • Storage: useLocalStorage, useSessionStorage
  • Timing: useDebounce, useDebouncedValue, useThrottle, useInterval, useTimeout
  • DOM: useClickOutside, useHover, useIntersectionObserver, useEventListener
  • Browser: useMediaQuery, useClipboard, useNetwork, useWindowSize, useElementSize, useIdle
  • State: useToggle, useDisclosure, usePrevious, useCounter, useList, useMap, useSet
  • Next.js: useHydrated, useIsServer, useIsomorphicLayoutEffect
  • Input: useHotkeys, useLongPress
  • Specialized: useFullscreen, useGeolocation, useOrientation, useColorScheme, useDocumentTitle, useFavicon, useHash, useMouse

Core Principles

  • SSR Safety: guard all browser APIs; return sensible defaults on the server.
  • TypeScript First: strict typing, exported types, inference-friendly signatures.
  • Consistent APIs: predictable return shapes per hook category.
  • Cleanup Guarantees: listeners, timers, observers cleaned up on unmount.
  • Options Objects: extensible options instead of positional params.

Project Structure

src/
  hooks/
    state/       # useToggle, useDisclosure, usePrevious, ...
    storage/     # useLocalStorage, useSessionStorage
    dom/         # useClickOutside, useHover, useIntersectionObserver
    timing/      # useDebounce, useThrottle, useInterval, useTimeout
    browser/     # useMediaQuery, useClipboard, useNetwork
    nextjs/      # useHydrated, useIsServer
    index.ts     # category barrels
  utils/         # isServer, noop, types
  index.ts       # root barrel and per-hook exports
__tests__/       # mirrors src structure
docs/            # guides

Scripts

  • lint — ESLint over src and tests
  • format / format:write — Prettier check / write
  • typechecktsc --noEmit
  • test — Vitest run
  • build — Rollup (ESM/CJS + types)

Development

npm install
npm run lint
npm run typecheck
npm run test
npm run build

Testing

  • Vitest + @testing-library/react
  • Mock browser APIs where needed (localStorage, matchMedia, IntersectionObserver)
  • npm run test -- --watch for watch mode

Documentation

Comprehensive documentation for each hook is available in the docs/ directory. Each hook includes:

  • API Reference: Complete TypeScript interfaces and method signatures
  • Usage Examples: React and Next.js implementation examples
  • Best Practices: Recommended patterns and common use cases
  • SSR Considerations: Server-side rendering safety guidelines

Available Hooks

Storage Hooks

Browser Hooks

DOM Hooks

  • useClickOutside - Detect clicks outside specified elements (modals, dropdowns)
  • useHover - Hover state detection with configurable delays
  • useWindowSize - Window dimensions tracking with debounce/throttle
  • useElementSize - Element size observation and tracking (Work in progress)

REMAINING HOOKS ARE WORK IN PROGRESS

License

MIT