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 🙏

© 2025 – Pkg Stats / Ryan Hefner

qol-hooks

v2.1.4

Published

A collection of React hooks to improve the quality of life of developers.

Downloads

62

Readme

QOL Hooks

License npm version npm downloads

Description

(Qaulity of Life)

QOL Hooks is a collection of useful hooks for enhancing the quality of life in your React applications. These hooks provide common functionalities that can be easily integrated into your projects.

Installation

To initialize QOL Hooks, run:

npx qol-hooks init

Then install whatever hooks you need:

npx qol-hooks install useClipboard

Or just install all of them:

npx qol-hooks install all

Available Hooks

useClipboard

A hook that allows you to copy text to the clipboard.

Usage

import { useClipboard } from "qol-hooks";

const Component = () => {
	const [copied, copy] = useClipboard();

	return (
		<div>
			<button onClick={() => copy("Hello, World!")}>Copy</button>
			{copied && <p>Copied to clipboard!</p>}
		</div>
	);
};

useDebounce

A hook that debounces a value.

Usage

import { useDebounce } from "qol-hooks";

const Component = () => {
	const [value, setValue] = useState("");
	const debouncedValue = useDebounce(value, 500);

	return (
		<div>
			<input
				value={value}
				onChange={(e) => setValue(e.target.value)}
				placeholder='Debounced input'
			/>
			<p>Debounced value: {debouncedValue}</p>
		</div>
	);
};

useEventListener

A hook that allows you to add event listeners to the document.

Usage

import { useEventListener } from "qol-hooks";

const Component = () => {
	useEventListener("click", () => {
		console.log("Document clicked!");
	});

	return <div>Click anywhere on the document!</div>;
};

useFetch

A hook that fetches data from an API.

Usage

import { useFetch } from "qol-hooks";

const Component = () => {
	const [data, loading, error] = useFetch(
		"https://jsonplaceholder.typicode.com/posts",
		{
			method: "GET",
		}
	);

	if (loading) return <p>Loading...</p>;
	if (error) return <p>Error: {error.message}</p>;

	return (
		<ul>
			{data.map((post) => (
				<li key={post.id}>{post.title}</li>
			))}
		</ul>
	);
};

useHover

A hook that detects whether an element is being hovered over.

Usage

import { useHover } from "qol-hooks";

const Component = () => {
	const [hoverRef, isHovered] = useHover();

	return <div ref={hoverRef}>{isHovered ? "Hovered" : "Not hovered"}</div>;
};

useInterval

A hook that sets an interval.

Usage

import { useInterval } from "qol-hooks";

const Component = () => {
	useInterval(() => {
		console.log("Interval triggered!");
	}, 1000);

	return <div>Check the console!</div>;
};

useInView

A hook that detects whether an element is in view.

Usage

import { useInView } from "qol-hooks";

const Component = () => {
	const [ref, inView] = useInView();

	return (
		<div ref={ref}>
			{inView ? "In view" : "Not in view"}
			<div style={{ height: "100vh" }}></div>
		</div>
	);
};

useKeyPress

A hook that detects key presses.

Usage

import { useKeyPress } from "qol-hooks";

const Component = () => {
	const pressed = useKeyPress("a");

	return <div>{pressed ? "A key pressed!" : "Press 'A'"}</div>;
};

useLocalStorage

A hook that allows you to store data in local storage.

Usage

import { useLocalStorage } from "qol-hooks";

const Component = () => {
	const [name, setName] = useLocalStorage("name", "");

	return (
		<div>
			<input
				value={name}
				onChange={(e) => setName(e.target.value)}
				placeholder='Enter your name'
			/>
			<p>Hello, {name || "Stranger"}!</p>
		</div>
	);
};

useOnClickOutside

A hook that detects clicks outside of an element.

Usage

import { useOnClickOutside } from "qol-hooks";

const Component = () => {
	const ref = useRef();
	useOnClickOutside(ref, () => {
		console.log("Clicked outside!");
	});

	return <div ref={ref}>Click outside this element!</div>;
};

useOnlineStatus

A hook that detects the online status of the user.

Usage

import { useOnlineStatus } from "qol-hooks";

const Component = () => {
	const online = useOnlineStatus();

	return <div>{online ? "Online" : "Offline"}</div>;
};

usePrevious

A hook that returns the previous value of a state.

Usage

import { usePrevious } from "qol-hooks";

const Component = () => {
	const [count, setCount] = useState(0);
	const prevCount = usePrevious(count);

	return (
		<div>
			<p>Current: {count}</p>
			<p>Previous: {prevCount}</p>
			<button onClick={() => setCount((prev) => prev + 1)}>Increment</button>
		</div>
	);
};

useScroll

A hook that detects the scroll position of the window.

Usage

import { useScroll } from "qol-hooks";

const Component = () => {
	const { x, y } = useScroll();

	return (
		<div>
			<p>Scroll X: {x}</p>
			<p>Scroll Y: {y}</p>
		</div>
	);
};

useSessionStorage

A hook that allows you to store data in session storage.

Usage

import { useSessionStorage } from "qol-hooks";

const Component = () => {
	const [name, setName] = useSessionStorage("name", "");

	return (
		<div>
			<input
				value={name}
				onChange={(e) => setName(e.target.value)}
				placeholder='Enter your name'
			/>
			<p>Hello, {name || "Stranger"}!</p>
		</div>
	);
};

useTimeout

A hook that sets a timeout.

Usage

import { useTimeout } from "qol-hooks";

const Component = () => {
	const [visible, setVisible] = useState(false);
	useTimeout(() => setVisible(true), 1000);

	return <div>{visible ? "Visible" : "Not visible"}</div>;
};

useToggle

A hook that toggles between two states.

Usage

import { useToggle } from "qol-hooks";

const Component = () => {
	const [isOn, toggle] = useToggle(false);

	return (
		<div>
			<button onClick={toggle}>{isOn ? "ON" : "OFF"}</button>
		</div>
	);
};

useWindowSize

A hook that detects the window size.

Usage

import { useWindowSize } from "qol-hooks";

const Component = () => {
	const { width, height } = useWindowSize();

	return (
		<div>
			<p>Window width: {width}</p>
			<p>Window height: {height}</p>
		</div>
	);
};

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.