Remix Utils - v9.3.1
    Preparing search index...

    Module Hook/Use Hydrated

    Note

    Install using bunx shadcn@latest add @remix-utils/use-hydrated.

    Note

    This depends on react.

    This hook lets you detect if your component is already hydrated. This means the JS for the element loaded client-side and React is running.

    With useHydrated, you can render different things on the server and client while ensuring the hydration will not have a mismatched HTML.

    import { useHydrated } from "remix-utils/use-hydrated";

    export function Component() {
    let isHydrated = useHydrated();

    if (isHydrated) {
    return <ClientOnlyComponent />;
    }

    return <ServerFallback />;
    }

    When doing SSR, the value of isHydrated will always be false. The first client-side render isHydrated will still be false, and then it will change to true.

    After the first client-side render, future components rendered calling this hook will receive true as the value of isHydrated. This way, your server fallback UI will never be rendered on a route transition.

    Functions

    useHydrated