react-use-section-observer
v1.0.1
Published
A react hook to track the visibility of elements in the viewport using Intersection Observer API
Maintainers
Readme
react-use-section-observer
A lightweight React hook to track element visibility using the Intersection Observer API and automatically apply an active class to matching links.
🎥 Demo

✨ Features
- 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
⚠️ Limitations
- Only vertical scrolling (Y-axis) is supported.
- Requires browser support for
IntersectionObserver.
📦 Installation
npm install react-use-section-observer