Docs
SSR
Server rendering and hydration safety for @kamod-ch/motion.
Rules
- Never call
animateduring SSR — hooks and components guard with environment checks and return noop controls server-side. - Render stable markup —
Motionrenders children immediately; animation runs inuseLayoutEffectafter hydration. - Reduced motion defaults to false when
matchMediais unavailable (Node, SSR).
Safe patterns
// OK — Motion renders static children on the server
<Motion initial={false} animate={fade.animate}>
Panel
</Motion>;
// OK — useAnimate returns noop controls without a mounted ref
const { ref, animate } = useAnimate();
Unsafe patterns
// Avoid — imperative animate in render
animate(element, { opacity: 1 });
Test SSR behavior with preact-render-to-string in your app or rely on package vitest SSR specs in @kamod-ch/motion.