Sanity Library Reference Docs
    Preparing search index...

    Variable SDKStudioContextConst

    SDKStudioContext: Context<StudioWorkspaceHandle | null> = ...

    React context that allows the SDK to auto-detect when it is running inside a Sanity Studio. The Studio provides a workspace handle via this context, and SanityApp reads it to derive projectId, dataset, and a reactive auth token — eliminating the need for manual configuration.

    This context is defined in @sanity/sdk-react and provided by the Studio. The Studio imports it from this package and wraps its component tree:

    import {SDKStudioContext} from '@sanity/sdk-react'

    function StudioRoot({children}) {
    const workspace = useWorkspace()
    return (
    <SDKStudioContext.Provider value={workspace}>
    {children}
    </SDKStudioContext.Provider>
    )
    }

    When SanityApp is rendered inside this provider, it auto-configures without any config prop:

    <SanityApp fallback={<Loading />}>
    <MyComponent />
    </SanityApp>