In this page

    Vue.js > Real-time updates

    Real-time updates

    Live updates can be extremely useful both for content editors and the regular visitors of your app/website:

    • Content-editors in Preview Mode can see drafts directly in the production website, without having to refresh the page;

    • Visitors can immediately see new content as it gets published, allowing all kinds of real-time interactions with your website/app (ie. live-news coverage).

    Thanks to the useQuerySubscription composable provided by the vue-datocms package you can get real-time updates for the page when the content changes. This function connects to the DatoCMS's Real-time Updates API to receive the updated query results in real-time, and is able to reconnect in case of network failures.

    Live updates are great both to get instant previews of your content while editing it inside DatoCMS, or to offer real-time updates of content to your visitors (ie. news site).

    Reference

    Please consult the vue-datocms package documentation to learn more about how to configure useQuerySubscription.

    The subscription can be created inside the component setup script. Please refer to the query-subscription example for a sample implementation.