Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Live content collections are a new type of [content collection](/en/guides/conte

## Basic usage

To enable the feature, add the `experimental.liveContentCollections` flag to your `astro.config.mjs` file:
To enable the feature, make sure you have an adapter configured for [on-demand rendering](/en/guides/on-demand-rendering/) and add the `experimental.liveContentCollections` flag to your `astro.config.mjs` file:

```js title="astro.config.mjs"
{
Expand Down Expand Up @@ -52,6 +52,8 @@ You can then use the dedicated `getLiveCollection()` and `getLiveEntry()` functi

```astro
---
export const prerender = false; // Not needed in 'server' mode

import { getLiveCollection, getLiveEntry } from 'astro:content';

// Get all products
Expand Down Expand Up @@ -126,6 +128,8 @@ You can then get content from both loaders with a unified API:

```astro
---
export const prerender = false; // Not needed in 'server' mode

import { getLiveCollection, getLiveEntry } from 'astro:content';

// Use loader-specific filters
Expand Down Expand Up @@ -155,6 +159,8 @@ These errors have a static `is()` method that you can use to check the type of e

```astro "LiveEntryNotFoundError.is(error)"
---
export const prerender = false; // Not needed in 'server' mode

import { getLiveEntry, LiveEntryNotFoundError } from 'astro:content';
const { entry, error } = await getLiveEntry('products', Astro.params.id);
if (error) {
Expand Down Expand Up @@ -281,6 +287,8 @@ You can then render both content and metadata from live collection entries in pa

```astro "render(entry)" "<Content />"
---
export const prerender = false; // Not needed in 'server' mode

import { getLiveEntry, render } from 'astro:content';
const { entry, error } = await getLiveEntry('articles', Astro.params.id);
if (error) {
Expand Down Expand Up @@ -350,6 +358,8 @@ When you use `getLiveCollection()` or `getLiveEntry()`, TypeScript will infer th

```astro
---
export const prerender = false; // Not needed in 'server' mode

import { getLiveEntry } from 'astro:content';
const { entry: product } = await getLiveEntry('products', '123');
// TypeScript knows product.data is of type Product
Expand Down Expand Up @@ -456,6 +466,8 @@ When you use `getLiveCollection()` or `getLiveEntry()`, TypeScript will infer th

```astro
---
export const prerender = false; // Not needed in 'server' mode

import { getLiveEntry } from 'astro:content';
const { entry, error } = await getLiveEntry('products', '123');
if (error) {
Expand Down Expand Up @@ -504,6 +516,8 @@ When using Zod schemas, validation errors are automatically caught and returned

```astro
---
export const prerender = false; // Not needed in 'server' mode

import { getLiveEntry, LiveCollectionValidationError } from 'astro:content';

const { entry, error } = await getLiveEntry('products', '123');
Expand Down Expand Up @@ -564,6 +578,8 @@ You can then use these hints in your pages:

```astro
---
export const prerender = false; // Not needed in 'server' mode

import { getLiveEntry } from 'astro:content';

const { entry, error, cacheHint } = await getLiveEntry('products', Astro.params.id);
Expand Down