Claude Code Setup for 3D Scroll Websites, Step by Step
By Md Mahafuj Alam · Updated
What you need before you start
This guide sets up the code side of a scroll-driven 3D site. It assumes you already have, or will soon have, a set of frames cut from a video, as described in the complete guide to building a 3D motion website with Claude. You need:
- A terminal and Node.js installed, so you can run
npxandnpm. - An account Claude Code can sign in with. The Claude Code quickstart lists a Claude subscription (Pro, Max, Team or Enterprise), a Claude Console account, or access through a supported cloud provider.
- Git, so every step Claude takes can be reviewed and undone.
- A phone on the same Wi-Fi network as your computer, for testing.
Install Claude Code
Anthropic recommends the native installer. On macOS, Linux and WSL, run this in a terminal (Windows PowerShell, Homebrew and WinGet commands are on the quickstart page):
curl -fsSL https://claude.ai/install.sh | bashOpen a new terminal window and confirm it worked:
claude --versionA working install prints a version number. If the shell reports that claude is not found, the install directory is not on your PATH yet; the quickstart links to the fix. You start a session by running claude inside a project folder, and it asks you to log in the first time.
Scaffold the Next.js project
Create the project yourself rather than asking Claude to do it. The scaffold is a one-line command and you want a clean, known starting point. The flags below are from the create-next-app reference:
npx create-next-app@latest scroll-story --ts --app --tailwind --eslint --use-npm
cd scroll-story--tssets up TypeScript (the default, stated explicitly here).--appuses the App Router.--tailwindand--eslintadd Tailwind CSS and ESLint. Drop either with--no-tailwindor--no-linterif you prefer.--use-npmbootstraps with npm. Swap for--use-pnpmor another manager if that is what you use.
Any option you do not pass is asked interactively. Recent versions of create-next-app also add an AGENTS.md file by default to guide coding agents towards current Next.js code. Keep it; the CLAUDE.md below imports it.
Commit the untouched scaffold before you change anything, so you always have a clean point to return to:
git add -A
git commit -m "Scaffold Next.js app"Install the animation packages
Four runtime packages cover the scroll stack, plus type definitions for three.js:
npm install gsap @gsap/react lenis three
npm install -D @types/three- gsap is the animation engine. ScrollTrigger ships inside it; the GSAP installation page states that all plugins are now freely available on npm. You still register each plugin with
gsap.registerPlugin(). - @gsap/react provides the
useGSAP()hook, which cleans up animations when a component unmounts. The GSAP React guide notes that in the App Router the file using it needs"use client"at the top. - lenis provides smooth scrolling. Its README documents the stylesheet at
lenis/dist/lenis.cssand a React wrapper atlenis/react. - three is three.js, for the optional real-time layer. It is imported as
import * as THREE from 'three'. The package does not ship its own TypeScript types, which is why@types/threeis added.
How these fit together, including driving Lenis from GSAP's ticker, is explained in GSAP ScrollTrigger with Lenis in Next.js.
Decide the folder layout before Claude does
Claude will invent a structure if you do not give it one, and it may invent a different one in each session. Settle the layout now and write it into CLAUDE.md. A layout that suits a scroll story:
app/
layout.tsx fonts, metadata, Lenis provider
page.tsx the story: chapters in order
components/
scroll/ SmoothScroll, ScrollSequence, Chapter
three/ optional real-time layer
lib/
frames.ts frame counts, paths, tier logic
story.ts chapter copy and timing
public/
frames/
desktop/ frame_0001.jpg ... landscape, full quality
desktop-preview/ same frames, small and light
mobile/ 9:16 portrait set
mobile-preview/Separate preview folders make progressive loading simple: the light tier loads first so the scrub works at once, then full-quality frames replace it. If you have not cut your frames yet, see how to convert video to an image sequence with ffmpeg.
Write the CLAUDE.md
CLAUDE.md is a Markdown file of instructions that Claude Code reads at the start of every session. According to Anthropic's memory documentation, a project file lives at ./CLAUDE.md or ./.claude/CLAUDE.md, and it is shared with your team through version control. The same page makes three points that shape how you write it:
- It is context, not enforced configuration. Concrete, verifiable instructions are followed more consistently than vague ones.
- Keep it under about 200 lines. Longer files consume more context and reduce adherence.
- It replaces AGENTS.md by default. When a
CLAUDE.mdexists, Claude reads it instead ofAGENTS.md. Put@AGENTS.mdon the first line to import the Next.js guidance as well.
You can run /init inside a session to generate a starting file from your codebase, then edit it. For a fresh scaffold, writing it by hand is faster. Here is a complete example to adapt:
@AGENTS.md
# Project
A single-page scroll story. Scroll position drives a canvas image
sequence; copy is revealed in pinned chapters. Optional three.js light
layer on top of the canvas.
# Stack
- Next.js App Router, TypeScript (strict). No Pages Router.
- GSAP + ScrollTrigger for all scroll-linked animation. Use useGSAP()
from @gsap/react, never raw useEffect for GSAP code.
- Lenis for smooth scroll, driven by gsap.ticker (autoRaf: false).
There must be exactly one requestAnimationFrame loop.
- three.js only inside components/three/. Never import three in a
server component.
- Tailwind for layout. Colours are CSS variables in app/globals.css.
# Commands
- Dev: npm run dev
- Type-check: npx tsc --noEmit
- Lint: npm run lint
- Build: npm run build (run before saying a task is done)
# Folders
- components/scroll/ SmoothScroll, ScrollSequence, Chapter
- components/three/ real-time layer, client-only
- lib/frames.ts the ONLY place frame counts and paths are defined
- lib/story.ts chapter copy and scroll lengths
# Frames
- Paths: /frames/{desktop,desktop-preview,mobile,mobile-preview}/frame_0001.jpg
- Numbering is 4-digit, 1-based, no gaps.
- Desktop frames are landscape; mobile frames are 9:16 portrait.
Pick the set with matchMedia on the client, never by user agent.
- Load the preview tier first, then upgrade to full quality.
- Never put frames in the JS bundle or import them as modules.
# Performance rules
- Draw frames to one <canvas>; never swap <img> src on scroll.
- Size the canvas backing store by devicePixelRatio, capped at 2.
- Only draw when the frame index changes.
- Keep decoded full-quality frames near the current index; release
far ones. No unbounded image caches.
- No layout reads (getBoundingClientRect, offsetHeight) inside scroll
callbacks.
- Animate transform and opacity only.
# Accessibility
- IMPORTANT: respect prefers-reduced-motion. Use gsap.matchMedia().
Reduced motion = no smooth scroll, no scrub; show one still frame
per chapter with the copy visible.
- All chapter copy must be real text in the DOM, not drawn on canvas.
- Canvas gets aria-hidden="true"; it is decorative.
# Workflow
- Work on one component per task. Show the plan before editing more
than two files.
- Do not add dependencies without asking.
- Do not change files in public/frames/.Run /context in a session to confirm the file loaded; it appears under memory files. When Claude ignores a rule, the documentation suggests the file may be too long, or the rule ambiguous. Prune before you add emphasis.
Work in small steps
A scroll story has several moving parts that interact: the smooth-scroll loop, ScrollTrigger's measurements, the canvas and the frame loader. If you ask for all of it at once, a bug in one hides inside the others. Anthropic's Claude Code best practices describe a workflow that suits this well: explore, plan, implement, commit.
- Plan mode for multi-file work. Press
Shift+Tabuntil the status bar shows plan mode, or start withclaude --permission-mode plan. Claude reads and proposes without editing. Approve the plan, then let it build. - One component per prompt. Build the sequence player, test it, commit. Then the scroll engine. Then chapters.
- Give it a check. Ask Claude to run
npx tsc --noEmitandnpm run buildafter each change and fix what fails. - Stop early. Press
Escto interrupt when Claude heads the wrong way; context is kept so you can redirect. - Clear between tasks. Run
/clearwhen you move to an unrelated task, so old attempts do not crowd the context.
Ready-made prompts for each of these steps are in Claude prompts for 3D scroll websites.
Review every diff
Claude Code shows the edits it makes in the session, and in Manual permission mode it asks before each file write. Read those changes either way. For scroll code in particular, look for:
- A second
requestAnimationFrameloop appearing next to the GSAP ticker. - Event listeners or ScrollTriggers created outside
useGSAP(), which will not be cleaned up. - Hard-coded frame counts outside
lib/frames.ts. - New packages in
package.jsonyou did not ask for.
Commit after each working step and use git diff to see exactly what changed. Claude Code also keeps checkpoints you can restore by pressing Esc twice or running /rewind, but the best practices page is explicit that checkpoints only track edits made through Claude's file tools, not changes made by shell commands, and are not a replacement for git.
Run the dev server and test on a phone
Start the dev server:
npm run devThe site is on http://localhost:3000. According to the Next.js CLI reference, next dev listens on 0.0.0.0 by default, so a phone on the same network can reach it at your computer's local IP address, for example http://192.168.1.20:3000.
Next.js blocks cross-origin requests to dev-only assets by default, and only allows localhost and the hostname the server started with. Add your computer's local IP to allowedDevOrigins so the phone gets hot reloading too:
import type { NextConfig } from 'next';
const nextConfig: NextConfig = {
allowedDevOrigins: ['192.168.1.20'],
};
export default nextConfig;Test on the phone after every chapter, not at the end. Portrait framing, memory limits and touch scrolling behave differently from a laptop, and problems are easier to fix while the change is small. The dev server is also slower than a production build, so judge smoothness with npm run build and npm run start. What to look for is covered in scroll animation performance on mobile.
Questions, answered.
The questions people ask most about this topic.
01How do I install Claude Code?
On macOS, Linux or WSL, run curl -fsSL https://claude.ai/install.sh | bash, open a new terminal and check it with claude --version. Anthropic also documents PowerShell, Homebrew and WinGet installs in the Claude Code quickstart.
02Where does CLAUDE.md go?
For a project, put it at ./CLAUDE.md or ./.claude/CLAUDE.md in the project root. Claude Code reads it at the start of every session. Personal preferences for all projects go in ~/.claude/CLAUDE.md instead.
03Should I keep the AGENTS.md that create-next-app adds?
Yes. When a CLAUDE.md exists, Claude reads it instead of AGENTS.md by default, so add @AGENTS.md as the first line of your CLAUDE.md to import it.
04Is GSAP ScrollTrigger free to use?
GSAP's installation page states that all plugins are now freely available on npm. ScrollTrigger is included in the gsap package and registered with gsap.registerPlugin(ScrollTrigger).
05Why can my phone load the page but not hot reload?
Next.js blocks cross-origin requests to dev-only assets unless the origin is localhost or the hostname the server started with. Add your computer's local IP address to allowedDevOrigins in next.config.ts.
Keep reading
- Start here · the full workflowHow to Build a 3D Motion Website with ClaudeBuild a 3D motion website with Claude: plan the story, generate keyframes and video, cut frames with ffmpeg, then build it in Next.js with GSAP and Lenis.Read the guide
- Guide · Workflow3D Scroll Website Prompts for Claude, Ready to CopyTwelve copy-and-paste Claude Code prompts for 3D scroll websites: canvas frame scrub, pinned chapters, Lenis, mobile frames, reduced motion and deploy.Read the guide
- Guide · BuildGSAP ScrollTrigger + Lenis in Next.js App RouterSet up GSAP ScrollTrigger and Lenis in the Next.js App Router: useGSAP scoping, the Lenis sync, a root provider, pinning, anchor links and reduced motion.Read the guide