Astro — overview
@ghostwritr/astro is a Content Layer loader. It pulls your site’s published articles into a content collection at build time — no file syncing, no CMS, no API key. Requires Astro 5+.
You define a collection with ghostwritr({ siteId }), and from then on it’s a normal Astro collection: getCollection, render, <Content />. The Markdown body arrives pre-compiled, the full article shape lands on entry.data, and removed articles drop out on the next build.
The 30-second example
Section titled “The 30-second example”npm install @ghostwritr/astro pnpm add @ghostwritr/astro yarn add @ghostwritr/astro bun add @ghostwritr/astro import { defineCollection } from "astro:content";import { ghostwritr } from "@ghostwritr/astro";
export const collections = { articles: defineCollection({ loader: ghostwritr({ siteId: import.meta.env.GHOSTWRITR_SITE_ID }), }),};---import { getCollection, render } from "astro:content";
export const getStaticPaths = async () => (await getCollection("articles")).map((p) => ({ params: { slug: p.id }, props: { p } }));
const { p } = Astro.props;const { Content } = await render(p);---<h1>{p.data.title}</h1><Content />That’s a statically-generated blog reading from the keyless feed. The quickstart fills in SEO and the byline.
Keyless by design
Section titled “Keyless by design”Reads hit your site’s static feed at feeds.ghostwritr.io/{siteId}/. The siteId is the unguessable read capability — there is no API key and no authed fallback. A missing feed fails closed: the loader throws a GhostwritrError with code NOT_FOUND and the build stops. See Keyless reads and The content feed.
Build-time only — pair with a redeploy hook
Section titled “Build-time only — pair with a redeploy hook”The loader runs during astro build. Articles published after a build won’t appear until the next build, so wire a deploy hook to the signed feed.updated webhook to rebuild on publish. See Redeploy on publish and Instant updates.
Where to go next
Section titled “Where to go next”- Quickstart — the full collection + article page, with SEO and the byline.
- Collection schema — the default
entry.datashape and how to narrow or extend it. - Rendering articles —
render(entry)and<Content />. - SEO & JSON-LD — drive head tags and structured data from
entry.data.