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

cf-hooks-lib

v1.1.4

Published

Librería de hooks de Cosmo Frameworks.

Readme

⚛️ cf-hooks

Build Status codecov npm

Librería profesional de React Hooks reutilizables, diseñados para mejorar la productividad, simplicidad y rendimiento en aplicaciones modernas con React.

🚀 Instalación

npm install cf-hooks-lib

⚠️ Esta librería requiere react como peerDependency. Asegúrate de tener React y React Dom 16+ instalado en tu proyecto.

🧩 Hooks disponibles

useDebounce

Ideal para optimizar búsquedas, inputs o eventos frecuentes.

const debouncedValue = useDebounce(value, delay);
  • value: cualquier valor que desees debilitar.
  • delay: tiempo de espera (en ms) antes de actualizar el valor.

useToggle

Útil para switches, modales, etc.

const [value, toggle, setOn, setOff] = useToggle(initialValue);
  • toggle(): invierte el valor actual.
  • setOn(): lo pone en true.
  • setOff(): lo pone en false.

useClickOutside

Asigna el ref al elemento que quieres proteger del clic externo.

const ref = useClickOutside(() => {
  // Se ejecuta cuando el usuario hace clic fuera del elemento
});

useIsMounted

Saber si un componente sigue montado. Útil para evitar actualizar estado tras unmount

const isMounted = useIsMounted();

useEffect(() => {
  fetchData().then((data) => {
    if (isMounted.current) {
      setData(data);
    }
  });
}, []);

useEventCallback

Devuelve un callback estable que no se vuelve a crear en cada render (memoria óptima).

const handleClick = useEventCallback(() => {
  console.log("Siempre la misma referencia");
});

useLocalStorage

Guarda y lee datos de localStorage de forma reactiva.

const [theme, setTheme] = useLocalStorage("theme", "light");

useSessionStorage

Igual que useLocalStorage, pero usa sessionStorage

const [step, setStep] = useSessionStorage("wizardStep", 1);

useSyncedState

Estado sincronizado entre pestañas usando localStorage.

const [name, setName] = useSyncedState("sharedName", "");

useMediaQuery

Detecta si el viewport coincide con una media query.

const isLarge = useMediaQuery("(min-width: 1024px)");

useWindowSize

Devuelve { width, height } actualizados al redimensionar la ventana.

const { width, height } = useWindowSize();

useElementSize

Mide dinámicamente el tamaño de un elemento (usa ResizeObserver).

const [ref, size] = useElementSize<HTMLDivElement>();
return <div ref={ref}>Ancho: {size.width}px</div>;

useIntersectionObserver

Detecta si un elemento está visible en el viewport (lazy load, animaciones, etc).

const [ref, isVisible] = useIntersectionObserver();
return <div ref={ref}>{isVisible ? "Visible" : "No visible"}</div>;

useHover

Saber si el mouse está encima de un elemento.

const [ref, hovering] = useHover<HTMLDivElement>();
return <div ref={ref}>{hovering ? "Hovering" : "Not hovering"}</div>;

useTimeout

Ejecuta una función una sola vez tras un tiempo.

useTimeout(() => {
  console.log("Timeout ejecutado");
}, 1000);

useInterval

Ejecuta una función repetidamente cada X milisegundos.

useInterval(() => {
  console.log("Cada segundo");
}, 1000);