Sanity Library Reference Docs
    Preparing search index...
    DefinedSanityFetchType: <const QueryString extends string>(
        options: {
            params?: QueryParams | Promise<QueryParams>;
            perspective?: LivePerspective;
            query: QueryString;
            requestTag?: string;
            stega?: boolean;
            tag?: never;
            tags?: string[];
        },
    ) => Promise<
        {
            data: ClientReturn<QueryString, unknown>;
            sourceMap: ContentSourceMap | null;
            tags: string[];
        },
    >

    Use this function to fetch data from Sanity in your React Server Components. When used within a generateMetadata or generateViewport function, make sure you set stega: false. When used within a generateStaticParams function, make sure you set stega: false and perspective: 'published'.

    Type declaration

      • <const QueryString extends string>(
            options: {
                params?: QueryParams | Promise<QueryParams>;
                perspective?: LivePerspective;
                query: QueryString;
                requestTag?: string;
                stega?: boolean;
                tag?: never;
                tags?: string[];
            },
        ): Promise<
            {
                data: ClientReturn<QueryString, unknown>;
                sourceMap: ContentSourceMap | null;
                tags: string[];
            },
        >
      • Type Parameters

        • const QueryString extends string

        Parameters

        • options: {
              params?: QueryParams | Promise<QueryParams>;
              perspective?: LivePerspective;
              query: QueryString;
              requestTag?: string;
              stega?: boolean;
              tag?: never;
              tags?: string[];
          }
          • Optionalparams?: QueryParams | Promise<QueryParams>

            Parameters used by the GROQ query.

          • Optionalperspective?: LivePerspective

            Content perspective used for the fetch.

            'published' or when in draft mode it's 'drafts' or the value of a cookie named 'sanity-preview-perspective' that is set by defineEnableDraftMode.

          • query: QueryString

            GROQ query to execute.

          • OptionalrequestTag?: string

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

            'next-loader.fetch'
            
          • Optionalstega?: boolean

            Enables stega encoding of the data. This is typically only used in draft mode with perspective: 'drafts' and @sanity/visual-editing.

            false or when in draft mode it's true

          • Optionaltag?: never

            use requestTag instead

          • Optionaltags?: string[]

            Add custom next.tags to the underlying fetch request.

            https://nextjs.org/docs/app/api-reference/functions/fetch#optionsnexttags This can be used in conjunction with custom fallback revalidation strategies, as well as with custom Server Actions that mutate data and want to render with fresh data right away (faster than the Live Event latency).

        Returns Promise<
            {
                data: ClientReturn<QueryString, unknown>;
                sourceMap: ContentSourceMap | null;
                tags: string[];
            },
        >