Once content has been saved in the CMS you'll want a way to retrieve it. Your CMS instance has methods to fetch specific entries or search through all content.
import {cms} from '@/cms'
export default async function HomePage() {
const homePage = await cms.get({type: HomePage})
return <h1>{homePage.title}</h1>
}There are multiple ways to retrieve your data, which one you use depends on how you want to receive it.
// Always returns an array
await cms.find()
// Returns the first result or null
await cms.first()
// Returns only one result or throws an exception
await cms.get()
// Returns the number of results
await cms.count() When querying items you will have to use the Query object for its two use cases:
Query.id // The unique identifier of the entry.
Query.title // The title of the entry.
Query.type // The name of the entry's type (e.g., 'BlogPost').
Query.url // The calculated public URL of the entry.
Query.path // The path segment of the entry (e.g., 'my-post').
Query.parentId // The ID of the parent entry.
Query.workspace // The workspace the entry belongs to.
Query.root // The root the entry belongs to.
Query.locale // The locale code of the entry (e.g., 'en', 'fr').
Query.status // The status of the entry (e.g., 'published').
Query.index // The sort index of the entry within its parent.