Skip to content

Lenis

A small JavaScript library that makes page scrolling smooth on websites.

Stars
17k
Forks
769
Licence
MIT
Language
TypeScript
Last update
7 days ago
Type
Library

What it is

Lenis is a lightweight JavaScript library that replaces the browser's default scrolling with a smoother, eased motion. It wraps the browser's own scroll, so features like sticky elements and anchor links keep working. People use it to add polished scroll effects such as WebGL scroll syncing and parallax to websites.

  • Add smooth vertical scrolling to a landing page with one initialization call
  • Sync a WebGL scene or GSAP animation to the scroll position using the scroll event
  • Enable smooth anchor-link navigation within a single-page layout
  • Use the snap plugin to align sections while keeping smooth scrolling

Great for

  • Web developers adding smooth scrolling to a marketing or portfolio site
  • Developers syncing animations like GSAP ScrollTrigger or WebGL scenes to scroll position
  • Teams using React, Vue, or Framer who want a ready-made adapter
  • Sites that need smooth anchor links and nested scroll areas

Not ideal for

  • Simple static pages where native scrolling is already sufficient, since the library adds motion and code to maintain
  • Projects that cannot load a JavaScript library, because it depends on JavaScript to run
  • Non-developers who want a no-code tool; the no-code option still requires editing HTML
Step-by-step guide: how to use LenisInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    Install with npm

    npm i lenis

    Install with yarn

    yarn add lenis

    Install with pnpm

    pnpm add lenis
  2. 2

    Run it

    • Install the package with npm, yarn, or pnpm
    • Import Lenis with import Lenis from 'lenis'
    • Create an instance with new Lenis({ autoRaf: true })
    • Optionally listen for scroll events with lenis.on('scroll', callback)
  3. 3

    Get the most out of it

    • Use the GSAP ScrollTrigger setup from the README to keep animations in sync with smooth scroll
    • Enable anchors, autoToggle, and stopInertiaOnNavigate options for smoother navigation behavior
    • Import the recommended lenis.css stylesheet as described in the Setup section
    • Review the Settings table for options like allowNestedScroll and autoResize to fit your layout

Downloads

Strengths

  • Lightweight with zero runtime dependencies, according to the README
  • Works with the browser's native scroll, keeping sticky positioning and accessibility intact
  • Offers framework packages for React, Vue, and Framer plus a snap plugin

Trade-offs

  • Scrolling behavior changes from the browser default, so it needs testing with your own content and users
  • Nested scroll handling via allowNestedScroll can hurt performance, as the README notes, and the prevent option is the alternative
  • Requires some setup for animation loops (autoRaf or a custom requestAnimationFrame loop) that beginners may find confusing

How it compares

ProjectStarsTypeLevelUpdatedBest for
lenis (this)17kLibrarybeginner7 days agoWeb developers adding smooth scrolling to a marketing or portfolio site
interact.js12.9kLibraryintermediate3 months agoWeb developers building drag-and-drop interfaces
element54kLibrarybeginner2.2 years agoDevelopers maintaining an existing Vue 2.x web application
headlessui28.8kLibraryintermediate7 months agoReact or Vue developers building custom-designed interfaces
element-plus27.8kLibraryintermediate4 days agoDevelopers building admin panels or business web apps with Vue 3
vant24.4kLibrarybeginner4 days agoTeams building mobile-first web apps or H5 pages in Vue

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.