On this page
The hero is where motion does the most good and the most harm. It is the first thing anyone sees, and it usually holds the page's Largest Contentful Paint, the moment Google uses to judge how fast your page loads. This guide shows how to build an animated hero in the Next.js App Router that still loads fast, with the specific mistakes we found and fixed on MotionKit's own homepage.
Keep the text on the server
Only the parts that move need to be client components. Put the animated background in a "use client" component that takes children, and pass the headline and buttons in from the server page. The text then arrives in the HTML, readable before any JavaScript runs, and the bundle holds only the background's code.
import { AuroraMesh } from "@/components/motionkit/aurora-mesh";
export default function Page() {
return (
<AuroraMesh className="flex min-h-[80svh] items-center justify-center px-6">
<div className="max-w-2xl text-center">
<h1 className="text-5xl font-semibold tracking-tight">Ship pages that feel alive</h1>
<p className="mt-5 text-lg text-white/70">Animated sections you paste in and own.</p>
</div>
</AuroraMesh>
);
}Never start the headline at opacity 0
Fading the headline in from opacity: 0 is the most common way to ruin a hero's score. Browsers don't count fully transparent text as painted, so Largest Contentful Paint waits until the animation finishes: on our homepage that cost a full second. Start from a barely visible value instead. It looks identical, but the text counts as painted from the first frame.
<motion.span
initial={{ opacity: 0.01, y: "0.4em", filter: "blur(10px)" }}
animate={{ opacity: 1, y: 0, filter: "blur(0px)" }}
transition={{ duration: 0.8, ease: [0.22, 1, 0.36, 1] }}
>
Ship pages that feel alive
</motion.span>Keep entrance animations short, under a second in total, and animate transform, opacity and filter only, so nothing moves the layout around the text.
Start heavy backgrounds late
A WebGL background is the most expensive thing on most landing pages. On a phone or laptop without a GPU, the browser draws WebGL on the CPU, and creating the first context alone can block the page for seconds. That is also how PageSpeed Insights runs its tests, which is why a beautiful shader hero can score in the thirties there.
- Show a still or CSS-animated fallback in the same colours first, so the hero never looks empty.
- Start the shader on the visitor's first pointer move, touch, scroll or key press. On desktop that is almost immediate.
- Where WebGPU reports only a software adapter, don't start it at all.
- Pause it when it scrolls out of view, and render below full resolution: soft shapes look the same at a fraction of the pixels.
Lighter backgrounds built from CSS gradients, SVG or a 2D canvas, like Aurora Mesh, Grain Gradient or Perspective Grid, can start straight away.
Keep the headline readable
Moving colour behind text is a contrast problem that changes every frame. Lay a soft radial darkening behind the headline so the brightest moment of the background still leaves 4.5:1 for body text and 3:1 for large headings. Check it against the brightest frame, not a quiet one.
<div aria-hidden className="pointer-events-none absolute inset-0 -z-[5]
bg-[radial-gradient(ellipse_55%_45%_at_50%_48%,rgb(7_8_13/0.72),transparent)]" />Respect reduced motion
Read useReducedMotion() from Motion and skip entrance animations entirely when it is on: set initial to false so the text renders in its final state. Backgrounds should show a single still frame. Anything that keeps looping for more than five seconds beside your content also needs a way to pause it.
Measure it
Test with Lighthouse in mobile mode and with PageSpeed Insights after you deploy. Look at Largest Contentful Paint and its breakdown: if most of the time is element render delay, something is hiding or delaying the text. If Total Blocking Time is high and the hero uses WebGL, the background is starting too early.