DEV Community

loading...

Discussion on: How to handle content previews from Sanity in Nuxt

Collapse
federicovezzoli profile image
Federico Vezzoli

Hi, very nice article, I'm trying to implement the real time update but it seems that the listener only reacts when I actually save the document, it does not emit an event when the content changes. Maybe something changed inside the client library? Have you experienced it? Thanks!

Collapse
mornir profile image
Jérôme Pott Author

Hey! I'm glad to know that my article was useful for you.
Maybe it's necessary to order the documents to be sure to get the draft first, like this:

this.$sanity.listen('*[_type == "movie" && slug.current == $slug][0] | order(_updatedAt desc)[0]'
Enter fullscreen mode Exit fullscreen mode

Like I mentioned in my post, I'm not really convinced by this approach for real-time live preview. The team at Sanity recently released a better real-time preview mode for Next.js which uses the @sanity/groq-store package under hood.
Hoping that next year we can get a similar library for Nuxt.

Forem Open with the Forem app