Next.js Discord

Discord Forum

new to nextjs need help

Answered
Mugger Crocodile posted this in #help-forum
Open in Discord
Mugger CrocodileOP
i connect my nextjs project with sanity every thing looks good but when i update data in sanity it doesn't upadted in nextjs server i thing there i problem with rendering can any one help me with this
Answered by not-milo.tsx
That's not correct. The fetch method accepts three arguments: query, params and options.
You need to pass the cache handling information to the options object and not to the query parameters.
const data = client.fetch(query, {}, {
  cache: 'no-store',
})


Don't mix up Sanity's client.fetch and Next.js' implementation of fetch. They have two different but overlapping APIs.
View full answer

5 Replies

Nope, that's not a problem with rendering. It's just that Next.js cahces your data by default so when you make changes in the studio you won't see them in your frontend immediately. Read up on [Next.js caching and revalidation](https://nextjs.org/docs/app/building-your-application/caching) first and then take a look at this [Sanity blog post](https://www.sanity.io/blog/sanity-nextjs-enhancements).
Mugger CrocodileOP
client.fetch(query,{ cache: "no-store" });
still facing the same problem
That's not correct. The fetch method accepts three arguments: query, params and options.
You need to pass the cache handling information to the options object and not to the query parameters.
const data = client.fetch(query, {}, {
  cache: 'no-store',
})


Don't mix up Sanity's client.fetch and Next.js' implementation of fetch. They have two different but overlapping APIs.
Answer
Mugger CrocodileOP
thank you brother its working now