Collection of React hooks for state management and side effects.
Note: Requires React 18 or later
# Using bun
bun add @rhinolabs/react-hooks
# Using npm
npm install @rhinolabs/react-hooks
# Using yarn
yarn add @rhinolabs/react-hooks
# Using pnpm
pnpm add @rhinolabs/react-hooks
-
useArray
- Array manipulation with built-in CRUD operations -
useLocalStorage
- Persistent state in localStorage -
useToggle
- Boolean state management -
usePrevious
- Access previous state values -
useInput
- Form input state handling
-
useDebounce
- Delay state updates for performance -
useFirstRender
- First render detection -
useScript
- Dynamic script loading -
useEventListener
- Optimized event handling
-
useTitle
- Document title management -
useFavicon
- Dynamic favicon updates -
useWindowSize
- Window dimensions tracking -
useScroll
- Scroll position monitoring -
useOnScreen
- Intersection observation -
useOutsideClick
- Click outside detection -
useKeyPress
- Keyboard event handling
-
useAudio
- Audio playback control -
useVideo
- Video playback control -
useDownload
- File download handling -
useClipboard
- Copy/paste operations
-
useFetch
- Data fetching with states -
useAsync
- Async operation handling -
useSearchParams
- URL parameter management -
useOffline
- Network status detection -
useNavigatorShare
- Web Share API
-
useGeolocation
- Location tracking -
useIsTouchDevice
- Touch capability detection -
useBattery
- Battery status monitoring -
useLang
- Language detection -
useFirstVisit
- First visit detection
-
useCountdown
- Countdown timer -
useCountup
- Count-up timer -
useStopwatch
- Stopwatch functionality -
useTimer
- General purpose timer
-
useRandomColor
- Random color generation
import { useArray } from "@rhinolabs/react-hooks"
function Example() {
const { array, push, remove, update } = useArray([1, 2, 3])
return (
<div>
<button onClick={() => push(4)}>Add 4</button>
<button onClick={() => remove(1)}>Remove second item</button>
<button onClick={() => update(0, 10)}>Update first to 10</button>
<p>Current array: {array.join(", ")}</p>
</div>
)
}
import { useLocalStorage } from "@rhinolabs/react-hooks"
function Example() {
const [value, setValue] = useLocalStorage("key", "default value")
return (
<input
value={value}
onChange={(e) => setValue(e.target.value)}
/>
)
}
import { useWindowSize } from "@rhinolabs/react-hooks"
function Example() {
const { width, height } = useWindowSize()
return (
<div>
Window size: {width} x {height}
</div>
)
}
- Clone the repository:
git clone https://github.com/rhinolabs/ui-toolkit.git
- Install dependencies:
bun install
- Build the package:
bun run build
Please read our Contributing Guidelines before submitting a pull request.
MIT © Rhinolabs Agency