TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/alineacms/alinea/llms.txt
Use this file to discover all available pages before exploring further.
cms object — created by createCMS and exported from your cms.ts file — is the primary interface for reading content. Under the hood it is backed by an in-memory SQLite database that is bundled with your Next.js build, so every call runs with zero network overhead and returns fully-typed results.
There are three core query methods:
| Method | Returns |
|---|---|
cms.find(query) | Promise<Array<Result>> — all matching entries |
cms.get(query) | Promise<Result> — single entry, throws if not found |
cms.count(query) | Promise<number> — count of matching entries |
cms.first(query), works like cms.get() but returns null instead of throwing when no entry is found.
Finding multiple entries
Pass atype to constrain results to one content type and a select object to project exactly the fields you need.
app/blog/page.tsx
Fetching a single entry
Usecms.get() when you expect exactly one result. The query throws an error if no matching entry is found, making it safe to use in Next.js generateStaticParams without null-checks.
app/blog/[slug]/page.tsx
app/blog/[id]/page.tsx
cms.first() when the entry may or may not exist:
app/blog/[slug]/page.tsx
Counting entries
cms.count() accepts the same query shape but returns an integer — useful for pagination metadata.
app/blog/page.tsx
The GraphQuery shape
Every query method accepts aGraphQuery object. The complete set of top-level options is:
Constrain results to one or more content types.
Project specific fields or nested graph queries. When omitted, all
EntryFields are returned.Merge additional field projections on top of the default
EntryFields result, without replacing the automatic type inference.Filter by entry fields or custom type fields. See Filtering & Ordering for the full filter API.
Shorthand to filter by entry id. Accepts a plain string or a condition object.
Filter entries by their direct parent id.
Filter by the entry’s path segment.
Filter by the full URL of the entry.
Exact locale match. Use
preferredLocale for a fallback strategy.Scope results to a workspace, root, or specific parent page.
Sort results. Each
Order object is {asc: Expr} or {desc: Expr}. See Filtering & Ordering.Return at most N results.
Skip the first N results.
Full-text search terms. Combine with
Query.snippet() to highlight matches.Control which entry lifecycle statuses are included. Defaults to
'published'.Status option
Thestatus option controls which version of an entry is returned.
'preferDraft' is useful in preview mode where you want editors to see unpublished changes. 'published' is the right default for public-facing pages.Fully-typed results
Alinea infers the TypeScript return type directly from the query’stype and select parameters via Type.Infer<T>. No manual type annotations are needed.
cms.ts
app/blog/page.tsx
cms.find<S, T, I> is resolved automatically from the query object literal, so TypeScript narrows the result array without any explicit generics.
Next steps
Filtering & Ordering
Apply
filter, orderBy, take, and skip to your queries.Graph Queries
Traverse children, parents, siblings, and translations inside a single query.
Editing API
Create, update, publish, and archive entries programmatically.
Configuration
Define content types, fields, workspaces, and roots.