A lightweight React hook to track element visibility using the Intersection Observer API and automatically apply an active class to matching links.
- Tracks visibility of multiple sections
- Automatically updates matching anchor links
- Supports custom root containers
- Supports multiple class names (e.g. Tailwind)
- No DOM mutation via
data-* - No external dependencies
- Fully typed (TypeScript)
- Adjustable to your DOM structure
- Only vertical scrolling (Y-axis) is supported.
- Requires browser support for
IntersectionObserver.
npm install react-use-section-observer