import "server-only"; import { createClient, type ClientConfig, type QueryParams } from "next-sanity"; import { projectId, dataset, apiVersion, token, mode } from "@/lib/env.api"; const config: ClientConfig = { projectId, dataset, apiVersion, useCdn: mode === "development" ? true : false, ignoreBrowserTokenWarning: true, token, perspective: "published", }; const client = createClient(config); export async function sanityFetch({ query, qParams = {}, tags, }: { query: string; qParams?: QueryParams; tags: string[]; }): Promise { return client.fetch(query, qParams, { cache: mode === "development" ? "no-store" : "force-cache", next: { tags }, }); }