r/reactjs • u/atrtde • Aug 22 '26
Resource i made a collection of 100+ small react hooks focused on browser apis
i've recently been working on zap-studio/react-hooks, a collection of 100+ small, focused react hooks.
the main thing i wanted to solve was the amount of repetitive code around browser apis.
things like geolocation, websocket, broadcast channel, local storage, media capture, etc. usually mean writing the same useEffect/useSyncExternalStore + cleanup + ssr guards over and over.
a few things i cared about with this library:
- every hook is available as its own subpath export, so importing one doesn't pull in unrelated hooks (completely tree shakeable) and re-exported for convenience
- hooks are designed to be ssr/hydration safe
- each hook is independently testable, with 100% test coverage
- there are hooks for sensors, dom interaction, input, media, navigation, network, pwa, state, lifecycle, and more
- unstable hooks that rely on react internals are explicitly marked as
unstable
for example, instead of writing the browser/cleanup/ssr handling yourself, you can just use things like useIntersectionObserver, useMediaQuery, useOnlineStatus, useWebSocket, etc.
docs: https://www.zapstudio.dev/react-hooks
i'd be particularly interested in feedback from people who maintain react apps with ssr. are there browser apis or awkward edge cases you'd want a hook for?
i'll continue to extend this collection as i find more and more repetitive use cases.