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.
- Gzipped
- 11.9 KB
- React APIs
- 10
- Unit tests
- 1077
- Dependencies
- 0
- 1
scrollRevealthe feature cards, staggeredFeaturesSection.tsx - 2
ScrollAnimatethe hero, faded up 40pxHeroSection.tsx - 3
scrollPinthe product shot, held in placeProductSection.tsx - 4
ScrollCounterthe stat, counted upStatsSection.tsx - 5
ScrollTextthe headline, word by wordHeadline.tsx
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.
'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>
);
}Quick start
Five patterns that cover most of a landing page — the same five numbered on the drawing above.
Step 01 · FeaturesSection.tsx
1. Reveal on scroll (the common case)
FeaturesSection.tsx'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> ); }Step 02 · HeroSection.tsx
2. Animate any CSS property
HeroSection.tsx'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> ); }Step 03 · ProductSection.tsx
3. Sticky pin section
ProductSection.tsx'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> ); }Step 04 · StatsSection.tsx
4. Animated counter
StatsSection.tsximport { 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> ); }Step 05 · Headline.tsx
5. Text reveal (replaces GSAP SplitText)
Headline.tsximport { 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> ); }
Every React API
- 01
scrollRevealsvg-scroll-draw/revealReveal elements on scroll. 7 presets, stagger, custom from state. Replaces AOS.
- 02
ScrollAnimatesvg-scroll-draw/reactAnimate any CSS property driven by scroll. Component wrapper around scrollAnimate.
- 03
ScrollDrawsvg-scroll-draw/reactWrap any inline SVG and its paths draw as you scroll. Presets, stagger, easing.
- 04
useScrollDrawProgresssvg-scroll-draw/reactHook that returns live 0–1 scroll progress for a ref, for driving your own UI.hook
- 05
ScrollTextsvg-scroll-draw/reactSplit text + stagger reveal. words, chars, or lines. Replaces GSAP SplitText.
- 06
ScrollCountersvg-scroll-draw/reactAnimated number counter driven by scroll. Format function, decimals, easing.
- 07
scrollPinsvg-scroll-draw/pinPin an element at a viewport position while content scrolls past it. Full lifecycle callbacks.
- 08
scrollSnapsvg-scroll-draw/snapSection snapping with custom easing. snapTo(), getCurrentIndex(), onSnap.
- 09
scrollProgresssvg-scroll-draw/progressExpose scroll progress as --scroll-progress CSS custom property. Drive CSS with calc().
- 10
scrollHorizontalsvg-scroll-draw/horizontalApple-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.
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.
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.
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 + 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.
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.
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.
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.
Questions React developers ask
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.
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.
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.
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.
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.
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.
Drop-in for React + Next.js
- Licence
- MIT
- Dependencies
- Zero
- Types
- TypeScript
- Unit tests
- 1077 tests
- Runs
- Everywhere React works