React Hooks
Typed React hooks for the browser problems every app hits.
Hooks
16+
Framework
Any React app
GitHub stars
1
npm downloads / month
233
Latest version
0.1.2
What I set out to do
Dark mode that doesn't flash the wrong theme on load. A search box that waits until you stop typing. A menu that closes when you click outside it. Every React app I built hit the same browser problems, and each fix had edge cases I'd solved before and forgotten. I wanted each one solved once, typed, tested, and ready to install in my next app.
What I built
16+ typed hooks and counting, published on npm as @timonwa/react-hooks, each solving one problem completely.
- Theming without the flash. Light, dark, and system themes, saved between visits, with a script that applies the right theme before the page appears. Hooks for media queries and the reduced-motion setting sit alongside.
- Overlays that behave. Dropdowns close on a click outside. Modals get Escape-to-close, scroll lock, and focus handling. Anything that unmounts can stay on screen long enough to animate out.
- Forms and timing. Debounce a search box, scroll a failed form back to its first error, and run countdowns.
- Files and copying. Preview a picked file without leaking memory, and show "Copied" on the exact button that was pressed.
- The page itself. Cookie consent, page titles, and knowing when the tab is hidden.
- Clear about where it runs. It's marked as client code, so frameworks like Next.js give a plain error if a hook is used on the server, instead of a confusing crash.
- No lock-in. It assumes no framework, router, styling library, or state library.
Who it's for
My own React apps first. These are the hooks I kept copying from project to project, shaped around how I build. They're open source, so if they fit your app too, install them.
Where it is now
Active and published on npm. New hooks arrive as new problems come up in my apps, or as other developers contribute them.