Skip to content
usefy

useIsomorphicLayoutEffect

Lifecycle & refs

An SSR-safe useLayoutEffect that falls back to useEffect on the server

Install

$ npm install @usefy/use-isomorphic-layout-effect

Quick start

useIsomorphicLayoutEffect.tsx
import { useIsomorphicLayoutEffect } from "@usefy/use-isomorphic-layout-effect";

useIsomorphicLayoutEffect(() => {
  const rect = ref.current?.getBoundingClientRect();
  setSize(rect);
}, []);

API reference

useIsomorphicLayoutEffect — resolves to useLayoutEffect in the browser and useEffect on the server. Same signature as useLayoutEffect.

Go deeper

This page is the quick reference. For every example, prop, and edge case, read the full README — or open Storybook to change props live.

More in lifecycle & refs