Sanity Library Reference Docs
    Preparing search index...

    Interface UseQueryOptionsDefinedInitial<QueryResponseResult>

    interface UseQueryOptionsDefinedInitial<QueryResponseResult = unknown> {
        initial: QueryResponseInitial<QueryResponseResult>;
    }

    Type Parameters

    • QueryResponseResult = unknown
    Index

    Properties

    Properties

    Initial data and sourceMap, used with SSR hydration and is required if ssr: true and an optional speed optimization if ssr: false. It's recommended to set initial to the return value of loadQuery().

    const query = `*[_type == "author" && slug.current == $slug][0]`
    export const getServerSideProps = async ({params}) => {
    const initial = await loadQuery<AuhthorType>(query, params)
    return { props: { params, initial } }
    }
    export default function Page({params, initial}) {
    const {data} = useQuery<AuthorType>(query, params, {initial})
    }