The Live Content API makes delivering fresh content at scale easy. With just a few lines of code, your applications can respond instantly to changes, serving up-to-date content to all users—no specialized infrastructure or dedicated engineering required.
The Live Content API enables you to create real-time applications with just a few lines of code. It powers subscriptions to fine-grained changes, ensuring your app responds instantly to any updates in relevant documents.
Check out this code example for the minimum setup in Next.js using the next-sanity package, and explore our documentation for installation guidance in other frameworks.
import { client } from "@/sanity/client"; import { defineLive } from "next-sanity"; const { sanityFetch, SanityLive } = defineLive({ client }); export default async function Page() { const {data: products} = await sanityFetch({ query: PRODUCTS_QUERY }); return ( <section> {products.map((product) => ( <article key={product._id}> <a href={`/product/${product.slug}`}>{product.title}</a> </article> ))} <SanityLive /> </section> ); }
The Live Content API sends events when fine-grained changes occur, so that the CDN is only partly invalidated. This change is propagated throughout the CDN as well as to individual end-users. Even under high-traffic scenarios with fast-moving such as Black Friday sales or limited edition releases – your application's data will be as fresh as the source from which it is consumed.
Watch the full episode→"Now, it’s just live by default. Sanity has absolutely come in to crush it with this one!"
The days of pressing refresh to get the latest products, promotions, news stories, or anything else are over.
Live content is pushed, not pulled. The content of your application should change when content at the source changes. The Live Content API makes it so.
Build a functional, content-driven and dynamic web application that best serves your end-users, fellow developers and content authors.
Learn from Sonny Sangha how to integrate Sanity's Live Content API with Next.js 15 to create a dynamic, production-ready e-commerce application
Real-time updates made easy on every plan. Start building today!
import { client } from "@/sanity/client";
import { defineLive } from "next-sanity";
const { sanityFetch, SanityLive } = defineLive({ client });
export default async function Page() {
const {data: products} = await sanityFetch({ query: PRODUCTS_QUERY });
return (
<section>
{products.map((product) => (
<article key={product._id}>
<a href={`/product/${product.slug}`}>{product.title}</a>
</article>
))}
<SanityLive />
</section>
);
}