Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

Issue with preview content not updating after publishing in Sanity Studio and Next.js app.

6 replies
Last updated: Dec 20, 2022
Hello,
I am using v2 in sanity studio. I am not able to see the preview content in local too. I have sanity studio and next js(frontend) app in two different repositories. I am following docs -


https://www.sanity.io/guides/nextjs-live-preview

https://www.sanity.io/docs/preview-content-on-site Video is attached. Thanks in advance.
Dec 20, 2022, 7:25 AM
do you have some form of revalidating the content you fetch from sanity? Having the same problem with live editing when i revalidate the content.
Dec 20, 2022, 7:31 AM
Hey
user U
,
No there is no revalidation in content. I just followed doc -
https://www.sanity.io/blog/build-your-own-blog-with-sanity-and-next-js .
Then I separated studio and FE app in different repos and deployed with vercel.
Dec 20, 2022, 7:34 AM
Would the preview update when you press publish?
Dec 20, 2022, 7:35 AM
I tried with changing title and check preview. Then I tried with update the title and click on publish. Again I have checked preview and i have not got any updates.
Dec 20, 2022, 7:38 AM
hey,
Above issue is solved now. I have not added FE code and I am expecting preview to run.

Now I get another issue to tackle in sanity. I am following
https://www.sanity.io/guides/nextjs-live-preview#284b10a97285 .
Now I am getting error in following line -

if (preview) {
return data.find((item) => item._id.startsWith(
drafts
)) || data[0]; }

I am getting following json in
data

 [
  {
    authorImage: { _type: 'image', asset: [Object] },
    body: [
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object]
    ],
    categories: [ 'Web', 'Frontend' ],
    name: 'Saurin Thakkar',
    title: 'My very first blog post[New Content Coming soon] sodium'
  },
  {
    authorImage: { _type: 'image', asset: [Object] },
    body: [
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object]
    ],
    categories: [ 'Web', 'Frontend' ],
    name: 'Saurin Thakkar',
    title: 'My very first blog post[New Content Coming soon] sew'
  }
] {
  authorImage: {
    _type: 'image',
    asset: {
      _ref: 'image-1c110ad195abfc4f7c43a7cbe49cbcac178027f1-8000x4910-jpg',
      _type: 'reference'
    }
  },
  body: [
    {
      _key: '0d2d679aa95f',
      _type: 'block',
      children: [Array],
      markDefs: [],
      style: 'h1'
    },
    {
      _key: '9a37a88637a5',
      _type: 'block',
      children: [Array],
      markDefs: [],
      style: 'normal'
    },
    {
      _key: 'fce417774166',
      _type: 'block',
      children: [Array],
      markDefs: [],
      style: 'normal'
    },
    { _key: '952b53df63f0', _type: 'image', asset: [Object] },
    {
      _key: '6034efcf3aa3',
      _type: 'block',
      children: [Array],
      markDefs: [],
      style: 'normal'
    },
    {
      _key: '3649cbf0b7d7',
      _type: 'block',
      children: [Array],
      level: 1,
      listItem: 'bullet',
      markDefs: [],
      style: 'normal'
    },
    {
      _key: '6e550197e84e',
      _type: 'block',
      children: [Array],
      level: 1,
      listItem: 'bullet',
      markDefs: [],
      style: 'normal'
    }
  ],
  categories: [ 'Web', 'Frontend' ],
  name: 'Saurin Thakkar',
  title: 'My very first blog post[New Content Coming soon] sodium'
}
There is no
item_id
in whole json to return object. So can anybody help give some advice for same.
Thanks
help
Dec 20, 2022, 2:02 PM
Thanks for sharing your solution
user D
!
Dec 20, 2022, 6:04 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?