Next.js parallax effect on next/image.
simpleParallax.js adds a parallax effect straight on the next/image Image component, in the App Router or the Pages Router. Wrap the image in SimpleParallax inside a Client Component: it keeps the image optimization, works with fill, placeholder="blur" and preload, and adds no layout shift.
Install the parallax library
npm install simple-parallax-jsyarn add simple-parallax-jspnpm add simple-parallax-jsbun add simple-parallax-jsAdd a parallax effect to next/image
Wrap the Image in SimpleParallax, in a Client Component (a file that starts with "use client"). Give the image a width and a height, as next/image requires.
"use client";
import Image from "next/image";
import SimpleParallax from "simple-parallax-js";
export default function Hero() {
return (
<SimpleParallax>
<Image src="/hero.jpg" alt="Mountain road at dusk" width={1800} height={1200} />
</SimpleParallax>
);
}Use it from a Server Component page
SimpleParallax uses React hooks, so a Server Component cannot render it directly. Put SimpleParallax and the Image together in a small Client Component, then use that component in your page.
"use client";
import Image, { type ImageProps } from "next/image";
import SimpleParallax from "simple-parallax-js";
export default function ParallaxImage(props: ImageProps) {
return (
<SimpleParallax>
<Image {...props} />
</SimpleParallax>
);
}// Server Component: no "use client" needed here.
import ParallaxImage from "./parallax-image";
export default function Page() {
return <ParallaxImage src="/hero.jpg" alt="Mountain road at dusk" width={1800} height={1200} />;
}Parallax on next/image with fill
With fill, the image is positioned against your own box, not against the wrapper added by the library. Give that box position: relative and overflow: hidden, and the parallax stays inside it.
"use client";
import Image from "next/image";
import SimpleParallax from "simple-parallax-js";
export default function Banner() {
return (
// fill positions the image against this box: it needs position and overflow: hidden.
<div style={{ position: "relative", aspectRatio: "16 / 9", overflow: "hidden" }}>
<SimpleParallax>
<Image
src="/hero.jpg"
alt="Mountain road at dusk"
fill
sizes="(min-width: 1024px) 1800px, 150vw"
style={{ objectFit: "cover" }}
/>
</SimpleParallax>
</div>
);
}Blur placeholder and preload
A statically imported image works as usual: the blur placeholder shows while the file loads, and the parallax starts once the image is ready.
"use client";
import Image from "next/image";
import SimpleParallax from "simple-parallax-js";
import hero from "./hero.jpg";
export default function Hero() {
return (
<SimpleParallax>
<Image src={hero} alt="Mountain road at dusk" placeholder="blur" preload />
</SimpleParallax>
);
}For an image above the fold, preload tells the browser to fetch it early. It replaces priority since Next.js 16; on Next.js 15 and earlier, use priority.
Pick the right image size
The parallax enlarges the image with a CSS scale (scale setting, 1.5 by default), not with the layout. next/image only sees the size of the box, so set sizes to the displayed width times the scale, or the browser may load a source that looks soft once scaled.
// Displayed 600px wide, scaled 1.5 times by the parallax: ask for a 900px source.
<SimpleParallax scale={1.5}>
<Image src="/hero.jpg" alt="Mountain road at dusk" width={1800} height={1200} sizes="(min-width: 1024px) 900px, 150vw" />
</SimpleParallax>With overflow set to true, the image is not scaled: sizes is simply the displayed width. All the settings (orientation, scale, delay, easing, overflow, maxTransition) are described in the settings reference.
Next.js parallax: frequently asked questions
Why does SimpleParallax fail in a Server Component?
The component uses React hooks to follow the scroll, so it only runs in a Client Component. Put SimpleParallax and the Image together in a file that starts with "use client", then render that component from your Server Component page.
Does it work with the Pages Router?
Yes. In the Pages Router every component runs on the client, so import SimpleParallax directly in your page or component, without the "use client" directive.
Is it safe with server-side rendering?
Yes. Nothing in the library touches window or document when it is imported. The image is rendered on the server at its normal place, and the effect starts in the browser once the image has loaded.
Does next/image with fill work?
Yes. With fill, the image is positioned against your own box, not against the wrapper added by the library. Give that box position: relative and overflow: hidden, and the parallax stays inside it.
Does the parallax hurt Core Web Vitals?
It does not move the layout. The image keeps its place and size, and the effect only changes its CSS transform, so it adds no layout shift. With width and height (or fill in a sized box), next/image reserves the space before the image loads.
Does it respect reduced motion?
Yes. When the visitor's system asks for reduced motion (prefers-reduced-motion: reduce), no parallax is applied and the image stays still.

