locomotive-scroll vs react-scroll vs scroll-behavior vs smooth-scroll
Smooth Scrolling and Scroll Management Libraries for Web Applications
locomotive-scrollreact-scrollscroll-behaviorsmooth-scrollSimilar Packages:

Smooth Scrolling and Scroll Management Libraries for Web Applications

locomotive-scroll, react-scroll, scroll-behavior, and smooth-scroll are JavaScript libraries that help manage scrolling behavior in web applications, but they serve different purposes and operate at different levels of abstraction. smooth-scroll provides basic smooth scrolling to anchor links using native browser APIs with polyfills. react-scroll is a React-specific library for managing scroll positions and linking navigation to scrollable sections. locomotive-scroll offers advanced scroll-driven animations and custom scroll mechanics by hijacking the native scroll. scroll-behavior is a low-level utility focused on synchronizing scroll state across browser history entries, primarily used in routing contexts.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
locomotive-scroll08,731526 kB92 months agoMIT
react-scroll04,419139 kB231a year agoMIT
scroll-behavior0545-376 years agoMIT
smooth-scroll05,454-26 years agoMIT

Smooth Scrolling and Scroll Management: locomotive-scroll vs react-scroll vs scroll-behavior vs smooth-scroll

When building modern web experiences, controlling how users scroll — whether for aesthetics, usability, or interactivity — is often essential. The four packages under review address this need in fundamentally different ways: from lightweight polyfills to full scroll hijacking. Let’s examine their technical approaches, trade-offs, and real-world applicability.

🎯 Core Purpose and Architecture

smooth-scroll is a minimal, vanilla JavaScript utility that enables smooth scrolling to anchor links. It detects browser support for the CSS scroll-behavior: smooth property and falls back to manual animation when needed. It does not override native scrolling — it only enhances programmatic jumps.

// smooth-scroll: Basic usage
import SmoothScroll from 'smooth-scroll';

const scroll = new SmoothScroll('a[href*="#"]', {
  speed: 500,
  offset: 0
});
// Automatically handles clicks on anchor links

react-scroll is a React-specific library that provides components and hooks to manage scroll position within a React app. It works with native scrolling and focuses on linking UI elements (like navigation menus) to scrollable sections.

// react-scroll: Linking nav to sections
import { Link, Element } from 'react-scroll';

function App() {
  return (
    <>
      <nav>
        <Link to="section1" spy={true} smooth={true}>Section 1</Link>
      </nav>
      <Element name="section1">Content here</Element>
    </>
  );
}

locomotive-scroll takes a radically different approach: it disables native scrolling entirely and simulates scroll using CSS transforms on a container. This allows for precise control over scroll velocity, direction, and timing — enabling complex effects like horizontal scrolling, parallax layers, and scroll-triggered animations.

// locomotive-scroll: Full scroll hijacking
import LocomotiveScroll from 'locomotive-scroll';

const scroll = new LocomotiveScroll({
  el: document.querySelector('[data-scroll-container]'),
  smooth: true
});
// Requires specific markup: <div data-scroll-container><div data-scroll>...</div></div>

scroll-behavior was designed to solve a narrow problem: synchronizing scroll position with browser history during client-side navigation (e.g., in SPAs). However, it is deprecated and should not be used in new projects. Modern routers handle this natively.

// scroll-behavior: Deprecated pattern (do not use)
import { install } from 'scroll-behavior';

// This approach is obsolete — React Router v6 uses window.history.scrollRestoration

⚙️ Implementation Model: Native vs Simulated Scroll

The biggest architectural divide is whether the library respects or replaces the browser’s native scroll mechanism.

  • smooth-scroll and react-scroll work on top of native scrolling. They trigger window.scrollTo() or element.scrollIntoView() with smooth behavior. This preserves accessibility (keyboard navigation, screen reader compatibility) and performance (browser-optimized rendering).

  • locomotive-scroll replaces native scrolling by applying transform: translate3d() to a container. This gives developers pixel-perfect control but breaks standard scroll behaviors: keyboard arrow keys don’t work, browser scrollbars disappear, and scroll-linked animations may jitter if not carefully optimized.

  • scroll-behavior attempted to patch native scroll restoration logic but is now irrelevant due to browser improvements.

🧩 Feature Comparison: What Each Can (and Can’t) Do

Smooth Anchor Navigation

All active packages support smooth scrolling to anchors, but with different ergonomics.

// smooth-scroll
new SmoothScroll('a[href*="#about"]');

// react-scroll (in JSX)
<Link to="about" smooth={true}>Go to About</Link>

// locomotive-scroll (requires manual API call)
scroll.scrollTo('#about');

// scroll-behavior — cannot do this; not its purpose

Scroll-Triggered Animations

Only locomotive-scroll provides built-in support for scroll-linked effects via data attributes:

<!-- locomotive-scroll -->
<div data-scroll data-scroll-speed="2">Parallax element</div>

react-scroll and smooth-scroll offer no such features. You’d need to combine them with Intersection Observer or GSAP for animations.

React Integration

react-scroll is purpose-built for React and provides hooks like useScroll() and components that respect React’s rendering cycle. The others are framework-agnostic:

// react-scroll: React-aware
const [activeSection, setActiveSection] = useState('home');

<Element name="home" onSetActive={() => setActiveSection('home')}>
  Home content
</Element>

Using locomotive-scroll in React requires manual cleanup and DOM refs:

// locomotive-scroll in React (more boilerplate)
useEffect(() => {
  const scroll = new LocomotiveScroll({ el: containerRef.current, smooth: true });
  return () => scroll.destroy();
}, []);

Accessibility and Performance

Because smooth-scroll and react-scroll use native scrolling, they inherit browser optimizations and accessibility features. locomotive-scroll requires extra work to restore these:

  • You must manually handle keyboard navigation.
  • Mobile performance can suffer if too many elements are transformed.
  • Screen readers may not announce scroll position changes.

🚫 Deprecation Warning: scroll-behavior

The scroll-behavior package is officially deprecated. Its README states: "This project is no longer maintained." Modern solutions like React Router v6’s built-in scroll restoration (<ScrollRestoration />) or the native history.scrollRestoration = 'manual' API make it obsolete. Do not use it in new projects.

🛠️ Real-World Decision Guide

Use Case: Marketing Landing Page with Section Nav

  • Best choice: react-scroll
  • Why? You need clickable nav that scrolls to sections, with active link highlighting. Native scroll keeps it fast and accessible.

Use Case: Interactive Storytelling Site with Parallax

  • Best choice: locomotive-scroll
  • Why? You need fine-grained control over scroll speed, direction, and element movement. The trade-off in accessibility is acceptable for this artistic context.

Use Case: Simple FAQ Page with Jump Links

  • Best choice: smooth-scroll
  • Why? Minimal setup, no framework dependency, and degrades gracefully in older browsers.

Use Case: SPA with Browser History Sync

  • Best choice: Don’t use any of these — rely on your router’s built-in scroll handling (e.g., React Router v6).

📌 Summary Table

PackageScroll ModelFrameworkKey StrengthAccessibilityMaintenance Status
locomotive-scrollSimulated (CSS)AgnosticAdvanced scroll effectsRequires workActive
react-scrollNativeReactDeclarative section navigationGoodActive
scroll-behaviorNative (patch)AgnosticScroll + history sync (obsolete)N/ADeprecated
smooth-scrollNative (polyfill)AgnosticSimple anchor smoothingGoodActive

💡 Final Recommendation

  • If you only need smooth anchor links, go with smooth-scroll — it’s tiny and reliable.
  • If you’re in React and building a section-based layout, react-scroll gives you clean, component-driven control.
  • If you’re crafting a cinematic, scroll-driven experience, locomotive-scroll is powerful but demands performance and accessibility diligence.
  • Avoid scroll-behavior — it’s outdated and unnecessary in modern apps.

Choose based on whether you need to enhance native scroll (smooth-scroll, react-scroll) or replace it (locomotive-scroll). Most projects fall into the first category — keep it simple unless you truly need custom scroll mechanics.

How to Choose: locomotive-scroll vs react-scroll vs scroll-behavior vs smooth-scroll

  • locomotive-scroll:

    Choose locomotive-scroll if you need advanced scroll effects like parallax, pinned elements, or custom scroll physics that go beyond native browser capabilities. It’s ideal for highly designed, interactive storytelling sites where scroll is a core interaction mechanic. Be aware it disables native scroll and requires careful handling of performance and accessibility.

  • react-scroll:

    Choose react-scroll if you’re building a React application that needs section-based navigation (like a single-page site with a sticky nav) and want declarative, component-driven control over scroll behavior. It integrates well with React’s lifecycle and works on top of native scrolling, making it lightweight and accessible by default.

  • scroll-behavior:

    Do not use scroll-behavior in new projects — it is deprecated and no longer maintained. The package was designed to manage scroll restoration in router-aware applications but has been superseded by built-in browser features and modern router libraries like React Router v6, which handle scroll behavior natively.

  • smooth-scroll:

    Choose smooth-scroll if you only need basic smooth scrolling to anchor targets (e.g., jump links) without heavy dependencies or custom scroll hijacking. It uses the native scroll-behavior: smooth CSS property when available and falls back to JavaScript animation, making it simple, accessible, and performant for straightforward use cases.

README for locomotive-scroll

Locomotive Scroll

npm version npm downloads bundle size

A lightweight & modern scroll library for detection, animation, and smooth scrolling. Built on top of Lenis.

Documentation

Full documentation available at scroll.locomotive.ca/docs.

Quick Start

npm install locomotive-scroll
import LocomotiveScroll from 'locomotive-scroll';

const scroll = new LocomotiveScroll();
@import 'locomotive-scroll/dist/locomotive-scroll.css';
<div data-scroll data-scroll-speed="0.5">I move at half speed</div>

Features

  • Lightweight — Only 9.4kB gzipped
  • TypeScript First — Fully typed
  • Built on Lenis — Latest stable release with improved performance
  • Dual Intersection Observers — Optimized detection for triggers vs. animations
  • Smart Touch Detection — Parallax auto-disabled on mobile
  • Accessible — Native scrollbar, keyboard navigation, proper ARIA support

Demo

Check out the examples and playground

Support

GitHub Issues