ComponentformZero dependencies

Hooks

SSR-safe React hooks: media query, localStorage, intersection, click-outside, copy, hotkey, and debounce.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add hooks

Or install the full npm package:

npm install bigbullui

Usage

tsx4 lines
import { useCopy } from "@/components/ui/lib/hooks"; const { copied, copy } = useCopy();<button onClick={() => copy("BB-2026")}>{copied ? "Copied!" : "Copy"}</button>

Source code

lib/hooks.ts

Zero third-party dependencies (only React + standard DOM APIs). Copy directly into your project:

tslib/hooks.ts311 lines
"use client"; import * as React from "react"; export function useMediaQuery(query: string): boolean {  const subscribe = React.useCallback(    (onStoreChange: () => void) => {      if (typeof window === "undefined" || typeof window.matchMedia !== "function") {        return () => {};      }      const match = window.matchMedia(query);      match.addEventListener("change", onStoreChange);      return () => match.removeEventListener("change", onStoreChange);    },    [query],  );  const getSnapshot = React.useCallback(    () =>

Props

PropTypeDescription
useCopy() => { copied: boolean; copy: (text: string) => void }Clipboard copy with copied flag.
useLocalStorage<T>(key: string, initial: T) => [T, setter]Persisted state hook.
useMediaQuery(query: string) => booleanSSR-safe media query match.
useDebounce<T>(value: T, delay: number) => TDebounced value hook.
useHotkey(combo, handler) => voidKeyboard shortcut hook.
useIntersection(options?) => ref + visibleIntersectionObserver hook.
useClickOutside(ref, handler) => voidOutside-click dismissal hook.