Sanity Library Reference Docs
    Preparing search index...

    Render this in your root layout.tsx to make your page refresh, or revalidate, on new content live, automatically.

    interface DefinedLiveProps {
        action?: SanityLiveAction;
        includeDrafts?: boolean;
        onError?: SanityLiveOnError;
        onGoAway?: false | SanityLiveOnGoaway;
        onReconnect?: false | SanityLiveOnReconnect;
        onRestart?: false | SanityLiveOnRestart;
        onWelcome?: false | SanityLiveOnWelcome;
        requestTag?: string;
        waitFor?: "function";
    }
    Index

    Properties

    Server action called for each content-change message from the Live Content API.

    The default action revalidates the cache tags produced by sanityFetch.

    includeDrafts?: boolean

    Include draft and content release version events in the live connection. Otherwise only events for published content are included.

    Requires browserToken to be configured in defineLive()

    The default is false unless

    • Cache Components are disabled
    • defineLive() was given a browserToken
    • defineLive() is not set to strict: true
    • draftMode() is enabled

    If all of the above conditions are met, then the default value will be true

    Custom error handler. If none is provided, errors are logged with console.error. Pass 'throw' to throw errors during render so they can be caught by the unstable_catchError API.

    onGoAway?: false | SanityLiveOnGoaway

    Custom handler for the goaway event. Pass false to disable the default long-polling fallback.

    onReconnect?: false | SanityLiveOnReconnect

    Custom handler for the reconnect event. Pass false to disable the default log behavior.

    onRestart?: false | SanityLiveOnRestart

    Custom handler for the restart event. Pass false to disable the default refresh behavior.

    onWelcome?: false | SanityLiveOnWelcome

    Custom handler for the welcome event. Pass false to disable the default connection log.

    requestTag?: string

    Request tag used to identify the live EventSource request in Sanity Content Lake logs.

    If cacheComponents: true then the default value is 'next-loader.live.cache-components' otherwise it's 'next-loader.live'

    waitFor?: "function"

    Delays events until after a configured Sanity Function has processed them and called the callback endpoint. When omitted, events are delivered immediately.