Skip to content

Astro

The Astro starter on the Node adapter, with drafts, a memory cache and a webhook that clears it.

DocsGet started

Docs menuAstro

The Astro starter runs as a server (Node adapter), so drafts in the visual editor and the revalidate webhook work. It lists a collection, renders any entry from your schema and counts visits with t.js. Download it from Connect your site → Astro → Starter, with your keys already in .env.

Setup in three steps

  1. Keys. Copy .env.example to .env (filled in the downloaded starter).
  2. Install. npm install, then npm run types (writes src/manifolio.d.ts).
  3. Run. npm run dev and open http://localhost:4321. In production: npm run build && npm start.

Caching and the webhook

Astro has no data cache of its own. src/lib/manifolio.ts keeps published responses in memory for five minutes; src/pages/api/revalidate.ts verifies the webhook signature and clears that cache. With several servers, purge your CDN there instead.

TypeScript
const client = preview
  ? createClient({ project, preview })                       // drafts, never cached
  : createClient({ project, key, fetch: cachedFetch });       // published, cached

A fully static Astro site works too: read in getStaticPaths, remove the adapter and point the webhook at your host's build hook. Drafts then need a separate server route.

Visual editor

src/middleware.ts allows framing by MANIFOLIO_ADMIN_ORIGIN and sends Cache-Control: private, no-store in preview. Preview URL: https://your-site/{type}/{slug}.

Until @manifolio/sdk is on npm, the downloaded starter carries it in vendor/manifolio-sdk.