Technique · GSAP ScrollTrigger

GSAP ScrollTrigger templates for Next.js

GSAP ScrollTrigger ties animations to the scrollbar: it pins sections, scrubs timelines and reports progress for canvas and WebGL scenes. Kestra, Orbitly and Zelvo use it together with Lenis smooth scrolling, in a Next.js codebase you own outright.

Templates built this way (2)

How it works

Under the hood.

SC.01

Pin, scrub and progress

ScrollTrigger is a GSAP plugin, imported separately from the core and registered once. Three options do most of the work in a scroll story, and the ScrollTrigger docs define them precisely:

OptionWhat it does
pin: trueHolds the trigger element in place while the trigger is active, and adds spacing so content below is not covered
scrub: trueLinks the animation progress directly to scroll progress
scrub: 0.5Same, but the playhead takes 0.5 seconds to catch up, which smooths it
start / endWhere the trigger begins and ends; start defaults to "top bottom", or "top top" when pinned; end defaults to "bottom top"
onUpdate(self)Called with the ScrollTrigger instance, whose progress runs from 0 to 1
hero.tsts
import { gsap } from 'gsap';
import { ScrollTrigger } from 'gsap/ScrollTrigger';

gsap.registerPlugin(ScrollTrigger);

const tl = gsap.timeline({
  scrollTrigger: {
    trigger: '#hero',
    start: 'top top',
    end: '+=3000',   // 3000px of scroll while pinned
    pin: true,
    scrub: true,
  },
});

tl.from('.caption-1', { autoAlpha: 0, y: 40 })
  .to('.caption-1', { autoAlpha: 0 }, '+=0.5')
  .from('.caption-2', { autoAlpha: 0, y: 40 });

One rule from the docs worth remembering: do not animate the pinned element itself, because that throws off ScrollTrigger's measurements. Animate its children.

SC.02

Driving a canvas or WebGL scene

Image sequences and three.js scenes are not DOM properties GSAP can tween directly. The pattern is to tween a plain object, or read self.progress, and hand the number to your renderer.

sequence-trigger.tsts
const state = { frame: 0 };

gsap.to(state, {
  frame: FRAME_COUNT - 1,
  ease: 'none',
  scrollTrigger: { trigger: '#hero', start: 'top top', end: '+=4000', pin: true, scrub: 0.3 },
  onUpdate: () => drawFrame(Math.round(state.frame)),
});

ease: 'none' keeps frames evenly spread over the scroll distance. Putting onUpdate on the tween rather than the ScrollTrigger matters with a numeric scrub: the docs note the animation keeps moving after scrolling stops, and you want to draw every step of that catch-up. The same number can just as well move a three.js camera. The image side is explained on the image sequence templates page.

SC.03

Adding Lenis smooth scrolling

All three templates pair ScrollTrigger with Lenis. Lenis smooths the scroll position itself, so ScrollTrigger needs to hear about every Lenis update, and both should run on one clock. The Lenis README gives the wiring:

smooth-scroll.tsts
import Lenis from 'lenis';
import { gsap } from 'gsap';
import { ScrollTrigger } from 'gsap/ScrollTrigger';

const lenis = new Lenis();
lenis.on('scroll', ScrollTrigger.update);
gsap.ticker.add((time) => {
  lenis.raf(time * 1000); // GSAP ticks in seconds, Lenis expects milliseconds
});
gsap.ticker.lagSmoothing(0);

Skip this when the visitor prefers reduced motion: every template here turns smooth scrolling off in that case and shows still frames instead.

SC.04

ScrollTrigger in Next.js and React

In React, triggers must be killed when a component unmounts, or a client-side navigation leaves stale pins behind. GSAP's useGSAP hook from @gsap/react handles this: it uses gsap.context() and reverts the animations and ScrollTriggers created inside it on unmount. In the App Router, the file that calls it needs 'use client'.

Hero.tsxtsx
'use client';
import { useRef } from 'react';
import { gsap } from 'gsap';
import { ScrollTrigger } from 'gsap/ScrollTrigger';
import { useGSAP } from '@gsap/react';

gsap.registerPlugin(ScrollTrigger, useGSAP);

export function Hero() {
  const root = useRef<HTMLElement>(null);
  useGSAP(() => {
    gsap.from('.headline', {
      autoAlpha: 0,
      y: 60,
      scrollTrigger: { trigger: '.headline', start: 'top 80%', scrub: true },
    });
  }, { scope: root });
  return (
    <section ref={root}>
      <h1 className="headline">Scroll to begin</h1>
    </section>
  );
}

After anything changes layout, such as fonts or images loading late, call ScrollTrigger.refresh() so start and end positions are measured again. The full setup is in the guide to GSAP ScrollTrigger and Lenis in Next.js.

When to use it

Right for the job, or not.

Pinned sections and multi-step timelines

Kestra pins a construction sequence with four stage panels sliding sideways; Zelvo pins its features section for an exploded view. ScrollTrigger handles the pin spacing and measurements for you.

Scroll stories that drive canvas or WebGL

Its progress value is a clean input for frame scrubbing or a three.js camera, with optional scrub smoothing.

Commercial client work

GSAP is now free for all users, and its standard license covers commercial use, with restrictions on building no-code animation tools that compete with Webflow. Read the license for your case.

Not for one or two simple reveals

A fade-in when an element enters the viewport needs an IntersectionObserver and a CSS transition, not a scroll library.

Not when CSS scroll-driven animations are enough and your browser targets allow it

CSS animation-timeline: scroll() runs without JavaScript, but MDN lists it as limited availability, not Baseline. Check support for your audience before relying on it alone.

FAQ

Questions, answered.

The questions people ask most about this topic.

01Is GSAP ScrollTrigger free to use?

GSAP states it is now 100% free for all users, thanks to Webflow, and its standard license says commercial use is covered. There are restrictions on competing no-code animation builders, so read the license on gsap.com.

02Does ScrollTrigger work with Next.js?

Yes. Use it in client components, register the plugin once, and use the useGSAP hook from @gsap/react so triggers are reverted on unmount. Kestra and Zelvo are built on the Next.js App Router, and Orbitly on Next.js 16.

03Why use Lenis with ScrollTrigger?

Lenis smooths native scrolling, which makes scrubbed animations feel less steppy on a mouse wheel. Wire lenis.on('scroll', ScrollTrigger.update) and drive Lenis from the GSAP ticker so both share one clock.

04What is the difference between scrub: true and a number?

scrub: true links animation progress directly to scroll. A number, such as 0.5, is the time in seconds the playhead takes to catch up, which adds smoothing.

05Which templates here use GSAP ScrollTrigger?

Kestra, Orbitly and Zelvo. MANJARI drives its three.js hero from scroll progress with Lenis smooth scrolling; its feature list does not name GSAP.

Start from a finished scroll story.