react / components & hooksworks with next.js app router, remix, vite

React scroll animations in 11.9 KB, zero deps

Typed React components and hooks for every scroll animation pattern — fade, slide, pin, snap, counter, text reveal, video scrub, horizontal sections. No GSAP. No Framer Motion. No config files.

API Reference →vs GSAP →
Gzipped
11.9 KB
React APIs
10
Unit tests
1077
Dependencies
0
localhost:3000Animate everything on scroll.40px50,000+counts 0 → 50,000pinned · top 80stagger 0.152431
  1. 1scrollRevealthe feature cards, staggeredFeaturesSection.tsx
  2. 2ScrollAnimatethe hero, faded up 40pxHeroSection.tsx
  3. 3scrollPinthe product shot, held in placeProductSection.tsx
  4. 4ScrollCounterthe stat, counted upStatsSection.tsx
  5. 5ScrollTextthe headline, word by wordHeadline.tsx
Fig. 1 — the page the quick start builds, one balloon per step
01The answer

Fade anything up, in one component

The copy-paste answer: a client component that wraps its children in ScrollAnimate and plays once. Use it anywhere, including inside a Server Component page.

FadeUp.tsx13 lines
'use client';
import { ScrollAnimate } from 'svg-scroll-draw/react';

export function FadeUp({ children }: { children: React.ReactNode }) {
  return (
    <ScrollAnimate
      props={{ opacity: [0, 1], transform: ['translateY(40px)', 'translateY(0)'] }}
      once
    >
      {children}
    </ScrollAnimate>
  );
}
02quick start · 5 steps

Quick start

Five patterns that cover most of a landing page — the same five numbered on the drawing above.

  1. Step 01 · FeaturesSection.tsx

    1. Reveal on scroll (the common case)

    FeaturesSection.tsx22 lines
    'use client';
    import { useEffect } from 'react';
    import { scrollReveal } from 'svg-scroll-draw/reveal';
    
    export function FeaturesSection() {
      useEffect(() => {
        const inst = scrollReveal('.feature-card', {
          preset:  'fadeUp',
          stagger: 0.1,
          once:    true,
        });
        return () => inst.destroy();
      }, []);
    
      return (
        <section>
          {features.map(f => (
            <div key={f.id} className="feature-card">{f.content}</div>
          ))}
        </section>
      );
    }
  2. Step 02 · HeroSection.tsx

    2. Animate any CSS property

    HeroSection.tsx38 lines
    'use client';
    import { useEffect, useRef } from 'react';
    import { scrollAnimate } from 'svg-scroll-draw';
    // Or use the component wrapper:
    import { ScrollAnimate } from 'svg-scroll-draw/react';
    
    // Hook style (imperative)
    export function HeroSection() {
      const ref = useRef<HTMLDivElement>(null);
    
      useEffect(() => {
        if (!ref.current) return;
        const inst = scrollAnimate(ref.current, {
          props: {
            opacity:   [0, 1],
            transform: ['translateY(40px)', 'translateY(0)'],
          },
          easing: 'ease-out',
          once:   true,
        });
        return () => inst.destroy();
      }, []);
    
      return <div ref={ref}>Hero content</div>;
    }
    
    // Component style (declarative)
    export function HeroDeclarative() {
      return (
        <ScrollAnimate
          props={{ opacity: [0, 1], transform: ['translateY(24px)', 'translateY(0)'] }}
          easing="ease-out"
          once
        >
          <div>Hero content</div>
        </ScrollAnimate>
      );
    }
  3. Step 03 · ProductSection.tsx

    3. Sticky pin section

    ProductSection.tsx29 lines
    'use client';
    import { useEffect, useRef } from 'react';
    import { scrollPin } from 'svg-scroll-draw/pin';
    
    export function ProductSection() {
      const imageRef = useRef<HTMLDivElement>(null);
    
      useEffect(() => {
        if (!imageRef.current) return;
        const inst = scrollPin(imageRef.current, {
          top:         80,                     // below fixed header
          pinDistance: '300vh',
          onEnter:     () => setActive(true),
          onLeave:     () => setActive(false),
        });
        return () => inst.destroy();
      }, []);
    
      return (
        <div style={{ display: 'flex', gap: 64 }}>
          <div ref={imageRef} style={{ width: '50%' }}>
            <img src="/product.webp" alt="Product" />
          </div>
          <div style={{ flex: 1 }}>
            {features.map(f => <FeatureBlock key={f.id} {...f} />)}
          </div>
        </div>
      );
    }
  4. Step 04 · StatsSection.tsx

    4. Animated counter

    StatsSection.tsx15 lines
    import { ScrollCounter } from 'svg-scroll-draw/react';
    
    export function StatsSection() {
      return (
        <div className="stats-grid">
          <ScrollCounter
            to={50000}
            format={n => Math.round(n).toLocaleString() + '+'}
            easing="ease-out"
            once
          />
          <ScrollCounter to={9} format={n => '~' + Math.round(n) + ' KB'} once />
        </div>
      );
    }
  5. Step 05 · Headline.tsx

    5. Text reveal (replaces GSAP SplitText)

    Headline.tsx15 lines
    import { ScrollText } from 'svg-scroll-draw/react';
    
    export function Headline() {
      return (
        <ScrollText
          split="words"
          stagger={0.07}
          from={{ opacity: 0, y: 32 }}
          easing="ease-out"
          once
        >
          <h1>Animate everything on scroll.</h1>
        </ScrollText>
      );
    }
03parts list · 10 apis

Every React API

  1. 01scrollRevealsvg-scroll-draw/reveal

    Reveal elements on scroll. 7 presets, stagger, custom from state. Replaces AOS.

  2. 02ScrollAnimatesvg-scroll-draw/react

    Animate any CSS property driven by scroll. Component wrapper around scrollAnimate.

  3. 03ScrollDrawsvg-scroll-draw/react

    Wrap any inline SVG and its paths draw as you scroll. Presets, stagger, easing.

  4. 04useScrollDrawProgresssvg-scroll-draw/react

    Hook that returns live 0–1 scroll progress for a ref, for driving your own UI.hook

  5. 05ScrollTextsvg-scroll-draw/react

    Split text + stagger reveal. words, chars, or lines. Replaces GSAP SplitText.

  6. 06ScrollCountersvg-scroll-draw/react

    Animated number counter driven by scroll. Format function, decimals, easing.

  7. 07scrollPinsvg-scroll-draw/pin

    Pin an element at a viewport position while content scrolls past it. Full lifecycle callbacks.

  8. 08scrollSnapsvg-scroll-draw/snap

    Section snapping with custom easing. snapTo(), getCurrentIndex(), onSnap.

  9. 09scrollProgresssvg-scroll-draw/progress

    Expose scroll progress as --scroll-progress CSS custom property. Drive CSS with calc().

  10. 10scrollHorizontalsvg-scroll-draw/horizontal

    Apple-style horizontal scroll sections driven by vertical scroll.

Have an SVG to draw? The SVG to JSX converter turns it into a typed React component, wrapped in ScrollDraw if you want, and the scroll reveal generator copies a ready React component for card reveals.

Want whole sections rather than parts? The blocks install one component each with the shadcn CLI, and scrollfx is a folio of full sections built on this library, each with a pen-plotter drawing that draws itself as you scroll.

Further reading: React scroll animations, compared, scroll animations in the Next.js App Router, and split text that screen readers still read.

04next.js

Next.js App Router

svg-scroll-draw is fully SSR-safe. All engines guard against window being undefined. In Next.js App Router, add 'use client' to any component that calls scroll APIs — or use dynamic(() => import(...), { ssr: false } ) to lazy-load entire animated sections.

app/page.tsx20 lines
import dynamic from 'next/dynamic';

// Option A: 'use client' component
// AnimatedHero.tsx starts with 'use client'
import { AnimatedHero } from '@/components/AnimatedHero';

// Option B: dynamic import with ssr: false
const AnimatedSection = dynamic(
  () => import('@/components/AnimatedSection'),
  { ssr: false }
);

export default function Page() {
  return (
    <>
      <AnimatedHero />
      <AnimatedSection />
    </>
  );
}

Server and client boundaries, route changes and cleanup are on the Next.js page.

05measured

Which React scroll animation library?

Four libraries cover most React scroll animation. Each is the right pick for some page; the sizes are minified and gzipped, measured the same way for all four.

GSAP + ScrollTrigger45.3 KB
Framer Motion34.3 KB
AOS6.7 KB
svg-scroll-draw11.9 KB
fig. 2 — bundle, minified + gzipped, to one scale

GSAP + ScrollTrigger

Bundle
45.3 KB
React API
useGSAP hook (@gsap/react)

Free since 2025 and the most capable: sequenced timelines for anything. Pick it when the page is one long choreographed piece.

Side by side →

Framer Motion

Bundle
34.3 KB
React API
useScroll, useTransform, motion.*

React-only, and also does layout, gesture and exit animation. Pick it when you already use it for those.

Side by side →

AOS

Bundle
6.7 KB
React API
none: data attributes + AOS.init()

Smaller, but reveal-on-scroll only, and last published 2022. Pick it for fades on a simple page.

Side by side →

svg-scroll-draw

Bundle
11.9 KB
React API
components + hooks

Scroll-tied drawing, reveals, pinning, text and video, on CSS scroll timelines where supported. Also Vue, Svelte, Solid, Angular.

All sizes minified + gzipped at level 9, measured 2026-08-14 against gsap 3.15.0, framer-motion 13.1.0, aos 2.3.4, svg-scroll-draw 2.31.0 — measured, not estimated.

066 questions

Questions React developers ask

Q1

What is the best scroll animation library for React?

It depends on the page. GSAP with ScrollTrigger handles long choreographed timelines best; Framer Motion fits if you already use it for layout and gestures; AOS covers simple fade-ins. svg-scroll-draw covers scroll-tied drawing, reveals, pinning, split text and video scrubbing in one small package, and hands the work to the browser's CSS scroll timeline where it can.

Q2

How do I animate an element when it scrolls into view in React?

Wrap it in <ScrollAnimate> with the properties to animate and once to play it a single time, as in the first example on this page. For many elements at once, call scrollReveal with a selector inside useEffect and return its destroy() for cleanup.

Q3

Can I do scroll animations in React without a library?

Yes. An IntersectionObserver that adds a class covers fade-ins, and CSS animation-timeline: view() ties an animation to scroll in browsers that support it. A library earns its place when you need a fallback for the browsers that don't, scrubbing back and forth, pinning, SVG path lengths or cleanup across route changes.

Q4

Is svg-scroll-draw a Framer Motion alternative?

For scroll-driven effects, yes, at a fraction of the size. It does not replace Framer Motion's layout animations, gestures or exit animations, so keep Framer Motion if a page relies on those.

Q5

Does it work with React Server Components and Next.js?

Yes. The components in svg-scroll-draw/react ship with 'use client', so a Server Component can render them directly; only function options such as onProgress need a client file of your own. On the server every call is a no-op, so rendering never touches window.

Q6

How do I clean up scroll animations in React?

The components clean up when they unmount. The plain functions return an instance: call them inside useEffect and return instance.destroy(), so nothing keeps listening after the component is gone.

07Drop it in

Drop-in for React + Next.js

Licence
MIT
Dependencies
Zero
Types
TypeScript
Unit tests
1077 tests
Runs
Everywhere React works
Full API docs →Live examples →