Problem with Sanity and Next js

created Sanity project it works great when I fetch but it is not updating in real time is there a thing with Next like special caching stuff. When I useCdn it changes but it is not up to date even if I refresh 10 times. Here is the code: import { createClient, groq } from "next-sanity"; export async function getPosts() { const client = createClient({ projectId: "MY ID", dataset: "production", apiVersion: "2023-09-15", useCdn: false, }); return client.fetch(groq*[_type == "post"]{ _id, _createdAt, title, "slug": slug.current, publishedAt, author, "mainImage": mainImage.asset->url, body }); }
1 Reply
ebitzu.
ebitzu.14mo ago
try moving the client declaration outside of the getPosts function so it doesn't get recreated
Want results from more Discord servers?
Add your server