### Install, Lint, and Test Dependencies Source: https://github.com/childrentime/reactuse/blob/main/CLAUDE.md Standard commands for managing project dependencies and running quality checks. Use these for local development setup and maintenance. ```bash pnpm install # install dependencies pnpm lint # eslint pnpm test # vitest ``` -------------------------------- ### Basic useRafState Example for a Floating Card Source: https://github.com/childrentime/reactuse/blob/main/packages/website-astro/src/content/blog/2026-05-27-react-render-loop-hooks.md This example demonstrates how to use `useRafState` to update the position of a floating card based on mouse movement. It shows the typical setup for visual state synchronization. ```tsx import { useRafState } from '@reactuses/core'; import { useEventListener } from '@reactuses/core'; function FloatingCard() { const [pos, setPos] = useRafState({ x: 0, y: 0 }); useEventListener('mousemove', (e) => { setPos({ x: e.clientX, y: e.clientY }); }); return (
{text}
Drop files into dropZone
{/*{JSON.stringify(state, null, 2)};
};
```
--------------------------------
### Complete Landing Page Example with Scroll Hooks
Source: https://github.com/childrentime/reactuse/blob/main/packages/website-astro/src/content/blog/2026-03-31-react-scroll-effects.md
This example integrates multiple scroll-related hooks to manage a landing page's dynamic elements, including a progress bar, sticky header, smooth scrolling to sections, and modal scroll locking. Ensure all necessary hooks are imported from '@reactuses/core'.
```tsx
import {
useScroll,
useScrollLock,
useScrollIntoView,
} from "@reactuses/core";
import { useSticky, useElementVisibility } from "@reactuses/core";
import { useRef, useState } from "react";
function LandingPage() {
const scrollContainerRef = useRefPlans and details here.
Page scroll is locked while this modal is open.
Press 'F' key to focus the button
{JSON.stringify(state, null, 2)};
};
```
--------------------------------
### GET /events
Source: https://github.com/childrentime/reactuse/blob/main/packages/website-astro/public/llms-full.txt
Establishes a Server-Sent Events connection for a specific channel. Clients can subscribe to real-time updates on a designated channel. The connection will periodically send heartbeat messages and broadcast updates at a specified interval.
```APIDOC
## GET /events
### Description
Establishes a Server-Sent Events (SSE) connection to receive real-time updates. Clients can specify a channel and an interval for receiving messages. The server sends periodic messages and heartbeats to maintain the connection.
### Method
GET
### Endpoint
/events
### Query Parameters
- **channel** (string) - Optional - The channel to subscribe to. Defaults to 'default'.
- **interval** (integer) - Optional - The interval in milliseconds between messages. Defaults to 3000.
### Response
#### Success Response (200)
- **Content-Type**: text/event-stream
- **Cache-Control**: no-cache
- **Connection**: keep-alive
- **X-Accel-Buffering**: no
- **Access-Control-Allow-Origin**: http://localhost:3000
- **Access-Control-Allow-Credentials**: true
### Response Example
(Connection established, subsequent messages are SSE formatted)
```
event: connected
id: 1678886400000
data: {"message":"Connected to SSE stream","channel":"default","time":"2023-03-15T10:00:00.000Z"}
event: broadcast
id: 1678886403000
data: {"id":1,"count":1,"channel":"default","time":"2023-03-15T10:00:03.000Z","message":"Channel default message 1"}
:
```
```
--------------------------------
### Get Device Pixel Ratio
Source: https://github.com/childrentime/reactuse/blob/main/packages/website-astro/public/llms-full.txt
Use this hook to display the current device pixel ratio. It is SSR-safe, returning a default of 1 on the server.
```tsx
function Demo() {
const { pixelRatio } = useDevicePixelRatio();
return Device pixel ratio: {pixelRatio}
; }; ``` -------------------------------- ### Check Component Mount Status with useMountedState Source: https://github.com/childrentime/reactuse/blob/main/packages/website-astro/public/llms-full.txt Use this hook to get a stable function that returns true if the component is mounted. Call the returned function (e.g., isMounted()) to check the status, which is useful for guarding state updates in async operations. ```tsx function Demo() { const isMounted = useMountedState(); const [, update] = useState(0); useEffect(() => { update(1); }, []); return