Sanity with Astro

This is the arrangement Sanity was designed for: one content model, queried by whatever needs it. Astro reads the documents at build and renders the pages, so there is no second CMS holding a copy and no sync to keep honest.

Sanity integrations like this usually take 1–2 weeks

How the handoff works.

  1. 01

    Document

    Published in Sanity

  2. 02

    Webhook

    The change leaves the Content Lake

  3. 03

    Map

    Portable Text and references resolved

    Key handoff

  4. 04

    Build

    The page rendered from the document

  5. 05

    Verify

    The rendered page against the document

Why this is the key handoff

One model, rendered. Sanity keeps the model and the editing workflow; the build renders it. Nothing is copied, so there is no second version of a document to fall out of step with the first, which is the failure mode of every arrangement that puts a CMS behind a CMS.

Three things that commonly go wrong.

  1. 01

    Portable Text is a decision, not a conversion

    Marks, blocks, embeds and custom objects each need a component to render them, and the ones nobody maps render as nothing at all. I go through the types actually in use rather than the ones the schema allows, because those are rarely the same list.

  2. 02

    Publishing in Sanity is not publishing on the site

    A built site shows what it was built with, so an edit reaches the public page when a build runs. A webhook from Sanity can start one within seconds, but the relationship has to be deliberate and visible, because nobody wants the answer to "is it live yet" to be a guess.

  3. 03

    Drafts and previews need their own path

    The published build reads published documents, which is correct and is not what an editor wants while writing. Preview is a separate mode reading drafts with its own token, and it is worth building properly rather than leaving editors to publish in order to see.

What is included.

  • Sanity documents queried at build, or on demand where a page needs to be current

  • Portable Text rendered as components rather than flattened to HTML

  • References synced in the right order

  • Assets copied or re-hosted where needed

  • Deletes, unpublishes and draft states handled cleanly

Reach out and see if we are a good fit.

Get in touch

Currently booking two to four weeks out.