Getting Started
@julianfere/hooked is a collection of type-safe, focused React hooks with zero dependencies beyond React itself.
Upgrading from 0.x?
1.0 requires React 19 and has breaking changes. Read the migration guide.
Installation
pnpm add @julianfere/hooked
npm install @julianfere/hooked
Entry points
The package ships two entry points:
| Import | Contents |
|---|---|
@julianfere/hooked | useAsync, useDebounce, useThrottle, useDelay, useLocalStorage, useQueryParams, useDocumentTitle (deprecated) |
@julianfere/hooked/events | factory (EventContext pub/sub system) |
Quick example
import { useAsync } from "@julianfere/hooked";
function UserProfile({ id }: { id: string }) {
const { data, status, trigger } = useAsync(
(signal) =>
fetch(`/api/users/${id}`, { signal }).then((r) => r.json())
);
if (status === "pending") return <p>Loading…</p>;
if (status === "rejected") return <p>Error loading user.</p>;
return (
<div>
<h1>{data?.name}</h1>
<button onClick={() => trigger()}>Refresh</button>
</div>
);
}
Requirements
- React 19+ (peer dependency)
- TypeScript 5.0+ (recommended)