"use client"
import dynamic from "next/dynamic"
const PulseShaderScene = dynamic(
() => import("@/components/ui/pulse-shader-scene"),
{
ssr: false,
loading: () => (
<div className="h-full w-full bg-zinc-100 dark:bg-neutral-950">
{/* Skeleton loader */}
</div>
),
}
)
export function PulseShaderDemo() {
return (
<div className="h-auto max-h-[400px] w-full overflow-hidden rounded-lg">
<PulseShaderScene imageSrc="https://cdn.badtz-ui.com/images/shaders/aurora-borealis-image.webp" />
</div>
)
}
pnpm dlx shadcn@latest add https://badtz-ui.com/r/pulse-shader.json
import dynamic from "next/dynamic";
const PulseShaderScene = dynamic(
() => import("@/components/ui/pulse-shader-scene"),
{
ssr: false,
loading: () => (
<div className="h-full w-full bg-zinc-100 dark:bg-neutral-950">
{/* Skeleton loader */}
</div>
),
},
);
<div className="w-full max-w-[620px] h-auto">
<PulseShaderScene imageSrc="/images/shaders/aurora-borealis-image.webp" />
</div>
You can use a placeholder while loading, to avoid potential issues, consider using dynamic imports.
By default, the shader is automatically disabled on mobile and replaced with a static image.
pulse-shader-scene
props.
Prop | Type | Default |
---|---|---|
imageSrc | string | - |
alt? | string | undefined |
marginFactor? | number | 1.05 |
Here are some of the key resources that helped me learn about shaders. If you're interested in exploring shaders further, these are great places to start!
The GLSL shader used in this component was created by @stegu
If you are using Next.js 14 or earlier, install these packages instead:
@react-three/[email protected]
@react-three/[email protected] gsap
pnpm add @react-three/[email protected] @react-three/[email protected] gsap three
THREE.WebGLRenderer: Context Lost
error occurring on Next.js 15 projects.