Sanity Library Reference Docs
    Preparing search index...

    Interface DefinedSanityLivePropsAlpha

    CAUTION: This API does not follow semver and could have breaking changes in future minor releases.

    interface DefinedSanityLiveProps {
        intervalOnGoAway?: number | false;
        onError?: (error: unknown) => void;
        onGoAway?: (
            event: LiveEventGoAway,
            intervalOnGoAway: number | false,
        ) => void;
        refreshOnFocus?: boolean;
        refreshOnMount?: boolean;
        refreshOnReconnect?: boolean;
        requestTag?: string;
        resolveDraftModePerspective?: () => Promise<ClientPerspective>;
        revalidateSyncTags?: (
            tags: (`sp:s1:${string}` | `sd:s1:${string}`)[],
        ) => Promise<void | "refresh">;
    }
    Index

    Properties

    intervalOnGoAway?: number | false

    Automatically refresh on an interval when the Live Event API emits a goaway event, which indicates that the connection is rejected or closed. This typically happens if the connection limit is reached, or if the connection is idle for too long. To disable this long polling fallback behavior set intervalOnGoAway to false or 0. You can also use onGoAway to handle the goaway event in your own way, and read the reason why the event was emitted.

    30_000 30 seconds interval

    onError?: (error: unknown) => void

    Handle errors from the Live Events subscription. By default it's reported using console.error, you can override this prop to handle it in your own way.

    onGoAway?: (event: LiveEventGoAway, intervalOnGoAway: number | false) => void

    Handle the goaway event if the connection is rejected/closed. event.reason will be a string of why the event was emitted, for example 'connection limit reached'. When this happens the <SanityLive /> will fallback to long polling with a default interval of 30 seconds, providing your own onGoAway handler does not change this behavior. If you want to disable long polling set intervalOnGoAway to false or 0.

    refreshOnFocus?: boolean

    Automatically refresh when window gets focused

    false

    refreshOnMount?: boolean

    Automatic refresh of RSC when the component is mounted.

    false

    refreshOnReconnect?: boolean

    Automatically refresh when the browser regains a network connection (via navigator.onLine)

    false

    requestTag?: string

    This request tag is used to identify the request when viewing request logs from your Sanity Content Lake.

    'next-loader.live'
    
    resolveDraftModePerspective?: () => Promise<ClientPerspective>

    Control how the draft mode perspective is resolved, by default it resolves from the sanity-preview-perspective cookie.

    revalidateSyncTags?: (
        tags: (`sp:s1:${string}` | `sd:s1:${string}`)[],
    ) => Promise<void | "refresh">

    Override how cache tags are invalidated, you need to pass a server action here. You can also pass a use client function here, and have router.refresh() be called if the promise resolves to 'refresh'.