Sanity.io content updates are not instantaneous in Next.js

108 views Asked by At

I am developing a project with Next.js and Sanity.io. I pull the necessary data with the client, assign them to variables and return the structures on the internal pages. However, I have such a problem; when I update my content on the sanity desk (even on localhost), the content is not updated instantly. I have changed many settings but still not successful. Here are some of my js files to help you:

sanity.js

import {createClient} from "next-sanity"

export const client = createClient ({
    dataset: process.env.NEXT_PUBLIC_SANITY_DATASET || "production",
    projectId: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID,
    apiVersion:"2021-10-21",
    useCdn: true,
})

getExperience.js

import { client } from '../../lib/sanity'

export default async function getExperience() {
    const query = `*[_type=="experience"] {
        title,
        jobTitle,
        description,
        startDate,
        endDate,
        _id,
    }`;

    const data = await client.fetch(query);
    return data;
}

Additionally, I tried to change the CLI values but I noticed that every time I change the API version, the data is updated. So when I change the date value once, the data is updated, but when I roll back to the previous date, the previous data comes back. I hope I was able to explain it.

0

There are 0 answers