# streamich/react-use architecture

> Architecture diagram of the GitHub repository streamich/react-use, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/streamich/react-use
- Repository: https://github.com/streamich/react-use

## Overview

react-use is a library of React hooks and hook factories. A consumer imports hooks from the package entry point and uses them to observe browser/device state, manage UI interactions, coordinate asynchronous work and timing, or maintain application state. Those hooks return state, callbacks, or controls for the consuming component. The README documents these capability areas; several implementations were not sampled, so their internal wiring is not inferred here.

Main entry points: [`src/index.ts`](https://github.com/streamich/react-use/blob/master/src/index.ts) (Public exports), [`src/useAsync.ts`](https://github.com/streamich/react-use/blob/master/src/useAsync.ts) (Async state), [`src/useAsyncFn.ts`](https://github.com/streamich/react-use/blob/master/src/useAsyncFn.ts) (Async callbacks), [`src/useKey.ts`](https://github.com/streamich/react-use/blob/master/src/useKey.ts) (Keyboard events)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sensors["Sensors and navigation"]
  node_device["Device sensors<br/>[useBattery.ts]"]
  node_geolocation["Geolocation<br/>[useGeolocation.ts]"]
  node_key["Keyboard events<br/>[useKey.ts]"]
  node_navigation["Location and query<br/>[useSearchParam.ts]"]
  node_other_sensors["Other sensor hooks"]
  node_event_helper["Event callback<br/>[useEvent.ts]"]
end

subgraph group_ui["UI and media"]
  node_drag_drop["Drop interactions<br/>[useDrop.ts]"]
  node_fullscreen["Fullscreen controls<br/>[useFullscreen.ts]"]
  node_media["Audio and video"]
  node_other_ui["Other UI hooks"]
  node_layout_effect["Layout effect"]
  node_drop_area["Drop area<br/>[useDropArea.ts]"]
end

subgraph group_state["State and storage"]
  node_counter["Counter state<br/>[useCounter.ts]"]
  node_shared_state["Shared state helpers<br/>[hookState.ts]"]
  node_set_state["Object state<br/>[useSetState.ts]"]
  node_storage["Browser storage<br/>[useLocalStorage.ts]"]
  node_other_state["Other state hooks"]
end

subgraph group_async["Async and timing"]
  node_async_hook["Async state<br/>[useAsync.ts]"]
  node_async_fn["Async callbacks<br/>[useAsyncFn.ts]"]
  node_retry["Async retry<br/>[useAsyncRetry.ts]"]
  node_timing["Animation and timers"]
  node_hook_lifecycle["Hook lifecycle<br/>[useEffectOnce.ts]"]
  node_mounted["Mounted-state check<br/>[useMountedState.ts]"]
end

node_consumer(("React consumer"))
node_api["Public exports<br/>[index.ts]"]

node_consumer -->|"imports hooks"| node_api
node_api -->|"exports"| node_device
node_api -->|"exports"| node_geolocation
node_api -->|"exports"| node_key
node_api -->|"exports"| node_navigation
node_api -->|"exports"| node_drag_drop
node_api -->|"exports"| node_fullscreen
node_api -->|"exports"| node_counter
node_api -->|"exports"| node_storage
node_api -->|"exports"| node_async_hook
node_api -->|"exports"| node_async_fn
node_api -->|"exports"| node_retry
node_api -->|"exports sensor hooks"| node_other_sensors
node_api -->|"exports UI hooks"| node_other_ui
node_api -->|"exports state hooks"| node_other_state
node_api -->|"exports timing hooks"| node_timing
node_counter -->|"resolves state"| node_shared_state
node_drop_area -->|"checks mounted"| node_mounted
node_key -->|"uses callback"| node_event_helper
node_fullscreen -->|"uses layout effect"| node_layout_effect
node_media -->|"updates state"| node_set_state
node_async_hook -->|"delegates to"| node_async_fn
node_retry -->|"wraps"| node_async_hook
node_async_fn -->|"checks mounted"| node_mounted

click node_api "https://github.com/streamich/react-use/blob/master/src/index.ts"
click node_device "https://github.com/streamich/react-use/blob/master/src/useBattery.ts"
click node_geolocation "https://github.com/streamich/react-use/blob/master/src/useGeolocation.ts"
click node_key "https://github.com/streamich/react-use/blob/master/src/useKey.ts"
click node_navigation "https://github.com/streamich/react-use/blob/master/src/useSearchParam.ts"
click node_other_sensors "https://github.com/streamich/react-use/tree/master/src"
click node_drag_drop "https://github.com/streamich/react-use/blob/master/src/useDrop.ts"
click node_fullscreen "https://github.com/streamich/react-use/blob/master/src/useFullscreen.ts"
click node_media "https://github.com/streamich/react-use/blob/master/src/factory/createHTMLMediaHook.ts"
click node_other_ui "https://github.com/streamich/react-use/tree/master/src"
click node_counter "https://github.com/streamich/react-use/blob/master/src/useCounter.ts"
click node_shared_state "https://github.com/streamich/react-use/blob/master/src/misc/hookState.ts"
click node_set_state "https://github.com/streamich/react-use/blob/master/src/useSetState.ts"
click node_storage "https://github.com/streamich/react-use/blob/master/src/useLocalStorage.ts"
click node_other_state "https://github.com/streamich/react-use/tree/master/src"
click node_async_hook "https://github.com/streamich/react-use/blob/master/src/useAsync.ts"
click node_async_fn "https://github.com/streamich/react-use/blob/master/src/useAsyncFn.ts"
click node_retry "https://github.com/streamich/react-use/blob/master/src/useAsyncRetry.ts"
click node_timing "https://github.com/streamich/react-use/tree/master/src"
click node_hook_lifecycle "https://github.com/streamich/react-use/blob/master/src/useEffectOnce.ts"
click node_mounted "https://github.com/streamich/react-use/blob/master/src/useMountedState.ts"
click node_event_helper "https://github.com/streamich/react-use/blob/master/src/useEvent.ts"
click node_layout_effect "https://github.com/streamich/react-use/blob/master/src/useIsomorphicLayoutEffect.ts"
click node_drop_area "https://github.com/streamich/react-use/blob/master/src/useDropArea.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_device,node_geolocation,node_key,node_navigation,node_other_sensors,node_event_helper toneBlue
class node_drag_drop,node_fullscreen,node_media,node_other_ui,node_layout_effect,node_drop_area toneAmber
class node_counter,node_shared_state,node_set_state,node_storage,node_other_state toneMint
class node_async_hook,node_async_fn,node_retry,node_timing,node_hook_lifecycle,node_mounted toneRose
class node_consumer toneIndigo
class node_api toneTeal
```

## Components

### Sensors and navigation

- [Device sensors](https://github.com/streamich/react-use/blob/master/src/useBattery.ts): `src/useBattery.ts`
- [Geolocation](https://github.com/streamich/react-use/blob/master/src/useGeolocation.ts): `src/useGeolocation.ts`
- [Keyboard events](https://github.com/streamich/react-use/blob/master/src/useKey.ts): `src/useKey.ts`
- [Location and query](https://github.com/streamich/react-use/blob/master/src/useSearchParam.ts): `src/useSearchParam.ts`
- [Other sensor hooks](https://github.com/streamich/react-use/tree/master/src): `src`
- [Event callback](https://github.com/streamich/react-use/blob/master/src/useEvent.ts): `src/useEvent.ts`

### UI and media

- [Drop interactions](https://github.com/streamich/react-use/blob/master/src/useDrop.ts): `src/useDrop.ts`
- [Fullscreen controls](https://github.com/streamich/react-use/blob/master/src/useFullscreen.ts): `src/useFullscreen.ts`
- [Audio and video](https://github.com/streamich/react-use/blob/master/src/factory/createHTMLMediaHook.ts): `src/factory/createHTMLMediaHook.ts`
- [Other UI hooks](https://github.com/streamich/react-use/tree/master/src): `src`
- [Layout effect](https://github.com/streamich/react-use/blob/master/src/useIsomorphicLayoutEffect.ts): `src/useIsomorphicLayoutEffect.ts`
- [Drop area](https://github.com/streamich/react-use/blob/master/src/useDropArea.ts): `src/useDropArea.ts`

### State and storage

- [Counter state](https://github.com/streamich/react-use/blob/master/src/useCounter.ts): `src/useCounter.ts`
- [Shared state helpers](https://github.com/streamich/react-use/blob/master/src/misc/hookState.ts): `src/misc/hookState.ts`
- [Object state](https://github.com/streamich/react-use/blob/master/src/useSetState.ts): `src/useSetState.ts`
- [Browser storage](https://github.com/streamich/react-use/blob/master/src/useLocalStorage.ts): `src/useLocalStorage.ts`
- [Other state hooks](https://github.com/streamich/react-use/tree/master/src): `src`

### Async and timing

- [Async state](https://github.com/streamich/react-use/blob/master/src/useAsync.ts): `src/useAsync.ts`
- [Async callbacks](https://github.com/streamich/react-use/blob/master/src/useAsyncFn.ts): `src/useAsyncFn.ts`
- [Async retry](https://github.com/streamich/react-use/blob/master/src/useAsyncRetry.ts): `src/useAsyncRetry.ts`
- [Animation and timers](https://github.com/streamich/react-use/tree/master/src): `src`
- [Hook lifecycle](https://github.com/streamich/react-use/blob/master/src/useEffectOnce.ts): `src/useEffectOnce.ts`
- [Mounted-state check](https://github.com/streamich/react-use/blob/master/src/useMountedState.ts): `src/useMountedState.ts`

### Other components

- **React consumer**
- [Public exports](https://github.com/streamich/react-use/blob/master/src/index.ts): `src/index.ts`

## Connections

- React consumer → Public exports: imports hooks (evidence: `src/index.ts`)
- Public exports → Device sensors: exports (evidence: `src/index.ts`)
- Public exports → Geolocation: exports (evidence: `src/index.ts`)
- Public exports → Keyboard events: exports (evidence: `src/index.ts`)
- Public exports → Location and query: exports (evidence: `src/index.ts`)
- Public exports → Drop interactions: exports (evidence: `src/index.ts`)
- Public exports → Fullscreen controls: exports (evidence: `src/index.ts`)
- Public exports → Counter state: exports (evidence: `src/index.ts`)
- Public exports → Browser storage: exports (evidence: `src/index.ts`)
- Public exports → Async state: exports (evidence: `src/index.ts`)
- Public exports → Async callbacks: exports (evidence: `src/index.ts`)
- Public exports → Async retry: exports (evidence: `src/index.ts`)
- Public exports → Other sensor hooks: exports sensor hooks (evidence: `src/index.ts`)
- Public exports → Other UI hooks: exports UI hooks (evidence: `src/index.ts`)
- Public exports → Other state hooks: exports state hooks (evidence: `src/index.ts`)
- Public exports → Animation and timers: exports timing hooks (evidence: `src/index.ts`)
- Counter state → Shared state helpers: resolves state (evidence: `src/useCounter.ts`)
- Drop area → Mounted-state check: checks mounted (evidence: `src/useDropArea.ts`)
- Keyboard events → Event callback: uses callback (evidence: `src/useKey.ts`)
- Fullscreen controls → Layout effect: uses layout effect (evidence: `src/useFullscreen.ts`)
- Audio and video → Object state: updates state (evidence: `src/factory/createHTMLMediaHook.ts`)
- Async state → Async callbacks: delegates to (evidence: `src/useAsync.ts`)
- Async retry → Async state: wraps (evidence: `src/useAsyncRetry.ts`)
- Async callbacks → Mounted-state check: checks mounted (evidence: `src/useAsyncFn.ts`)
