Skip to Content
ohooks

useIsomorphicLayoutEffect

Uses useLayoutEffect in browser environments and falls back to useEffect during server-side rendering to avoid React SSR warnings.

Loading preview...

The useIsomorphicLayoutEffect hook resolves to useLayoutEffect on the client (where window is defined) and useEffect on the server, allowing synchronous DOM measurements before paint without triggering SSR warnings.

Installation

pnpm dlx shadcn@latest add https://ohooks.vercel.app/r/useIsomorphicLayoutEffect.json

Usage