Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
"use client";
import { useEffect, useState } from "react";
/**
* Tracks the user's `prefers-reduced-motion` setting. Returns `false` until
* mounted (SSR-safe), then reflects the live media-query value. Shared by the
* docs preview surfaces so motion can be gated consistently.
*/
export function usePrefersReducedMotion() {
const [reduced, setReduced] = useState(false);
useEffect(() => {
if (typeof window === "undefined" || !window.matchMedia) return;
const mql = window.matchMedia("(prefers-reduced-motion: reduce)");
setReduced(mql.matches);
const onChange = (e: MediaQueryListEvent) => setReduced(e.matches);
mql.addEventListener("change", onChange);
return () => mql.removeEventListener("change", onChange);
}, []);
return reduced;
}