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

@cantabile/hooks

v1.2.1

Published

React hooks snippets for modern React (18 & 19)

Downloads

20

Readme

@cantabile/hooks

A modern, framework-friendly collection of TypeScript React hooks — built for React 18 & 19, fully compatible with both React Router and Next.js App Router.

Lightweight • Typed • Bun-optimized ⚡


📦 Installation

You can install with your preferred package manager:

# npm
npm install @cantabile/hooks

# yarn
yarn add @cantabile/hooks

# bun
bun add @cantabile/hooks

🪄 Core Hooks

| Hook | Description | | ---------------------------------- | ------------------------------------------------------------------- | | useClock() | Returns the current Date object and updates every second. | | useDebounce(handler, delay?) | Delays execution of a function until after a given delay. | | useImage({ src }) | Fetches an image from a URL and returns a blob URL. | | useOutsideAlerter(ref, handler?) | Detects clicks outside a specified element and triggers a callback. | | useWindowSize() | Returns [width, height] of the viewport and updates on resize. | | useBreakpoint(breakpoint) | Returns true if width < breakpoint. | | useElementSize(ref) | Returns [width, height] of an element and updates on resize. | | useReMountComponent(threshold?) | Remounts component periodically (default 30s) when window blurs. | | useOrientation() | Returns device orientation ("portrait" or "landscape"). | | useModalState(initial?) | Returns { state, open, close, toggle } for modal management. |


🌐 URL Hooks

This package supports both React Router and Next.js with separate entrypoints:

React Router

import { useQueryParams, useSetQueryParams } from "@cantabile/hooks/url-react";

const query = useQueryParams(["page", "search"]);
const setQuery = useSetQueryParams();

setQuery("page", "2");

Next.js (App Router)

import { useQueryParams, useSetQueryParams } from "@cantabile/hooks/url-next-app";

const query = useQueryParams(["tab"]);
const setQuery = useSetQueryParams();

setQuery("tab", "settings");

⚙️ Utility

| Hook / Function | Description | | ----------------- | ------------------------------------------ | | wait(ms?) | Promise-based delay helper for async flow. | | useModalState() | Reusable modal visibility state manager. |


🧩 Framework Compatibility

| Framework | Supported Versions | | ------------ | ------------------ | | React | 18.x, 19.x | | React Router | 6.26+ | | Next.js | 13.4+, 14.x, 15.x |


🧠 Example Usage

import { useClock, useBreakpoint } from "@cantabile/hooks";

export function DashboardHeader() {
  const now = useClock();
  const isMobile = useBreakpoint(768);

  return (
    <header>
      <p>{now.toLocaleTimeString()}</p>
      {isMobile && <p>📱 Mobile layout</p>}
    </header>
  );
}

🧱 Build & Development

bun run build
bun run lint
bun test

Uses Bun 1.3+, TypeScript 5.6+, and ESM + CJS dual build.


🪪 License

Licensed under the MIT License. © 2025 Wallop Opasakhun (ChampClarinet)