content.get()

Fetches one document by path from the handler's get route.

content.get(path)

Fetches one document by path from the handler's get route.

Parameters:

  • path: public path of the document (e.g. /posts/hello).

Returns: Promise<ContentFile<Data> | null>, null when the path doesn't resolve to a document.

usage.ts
const page = await content.get<PostFrontmatter>('/posts/hello')

Usage

usage.ts
const page = await content.get('/posts/hello')

Like its server counterpart, the client get() is typed against the generated path map, so a known path literal returns that path's data type without a type argument:

typed.ts
const page = await content.get('/posts/hello')
// page?.data: PostsData

Run type generation to populate the registry. Without it, data stays an open record, and an explicit type argument (content.get<PostFrontmatter>('/posts/hello')) still wins.