Headless WordPress Development

Publish in WordPress. Give your visitors a fast Astro website built around the content your team already knows how to manage.

  1. Block editor
  2. Database
  3. Content API
  4. Live homepage
WordPress saves the editor’s blocks. The API sends the selected fields in one response, and Astro uses them to render the homepage as HTML.

From a WordPress block to live HTML

Follow one homepage hero through four files. WordPress defines the editable fields and exposes them through its REST API. Astro validates the response at build time and renders the hero as HTML.

This example renders the hero without client-side JavaScript. The same approach works for the other blocks your team needs to publish.

block.json

{ 
  "apiVersion": 3,  
  "name": "red-rocks/hero",  
  "title": "Homepage hero",  
  "editorScript": "file:./index.js",  
  "attributes": {  
    "heading": { "type": "string" },  
    "summary": { "type": "string" } 
  }
}

page-api.php

 <?php  
add_action('rest_api_init', function () {  
    register_rest_field('page', 'hero', [  
        'get_callback' => function ($page) { 
            $post = get_post($page['id']); 
            if (!$post || $post->post_status !== 'publish' || $post->post_password !== '') {  
                return null; 
            } 
            foreach (parse_blocks($post->post_content) as $block) {  
                if ($block['blockName'] !== 'red-rocks/hero') continue;  
                return [  
                    'heading' => $block['attrs']['heading'] ?? '',  
                    'summary' => $block['attrs']['summary'] ?? '', 
                ];
            } 
            return null; 
        },
    ]);
});

homepage.ts

 import { z } from "zod"; 
 
const url = new URL(  
  "/wp-json/wp/v2/pages?slug=home&_fields=hero", 
  import.meta.env.WORDPRESS_ORIGIN,
); 
const response = await fetch(url);  
if (!response.ok) throw new Error("WordPress request failed"); 
 
const hero = z.object({  
  heading: z.string().trim().min(1),  
  summary: z.string(), 
}); 
const [home] = z.array(z.object({ hero })).parse(await response.json());  
if (!home) throw new Error("Homepage not found");  
export const homepageHero = home.hero; 

index.astro

 ---  
import Layout from "../layouts/Layout.astro";  
import { homepageHero } from "../content/homepage";  
  
export const prerender = true;  
const { heading, summary } = homepageHero;  
--- 
 
<Layout title={heading}>  
  <section aria-labelledby="homepage-heading">  
    <h1 id="homepage-heading">{heading}</h1>  
    <p>{summary}</p>  
  </section>  
</Layout> 

What we build for your team

A familiar editing experience

We give your team reusable blocks for the content you publish most, from landing pages to case studies. The front end applies your design system to each block.

Fast pages with less JavaScript

Astro can generate HTML before visitors arrive, resize images for different screens, and load JavaScript where an interaction needs it.

A migration with a launch plan

We map URLs, preserve useful content, and test redirects, forms, and analytics. Your team gets a handoff that covers previews, publishing, and routine updates.

Is headless WordPress right for you?

Decide what your editors, plugins, and publishing process need before choosing a setup.

Yes. We set up the blocks and patterns your team needs, then show editors how to build pages and preview changes before publishing.

A publish event can trigger an Astro rebuild for static pages. If a page needs current data on every request, we can render it on demand. We choose the approach based on how often the content changes.

Editorial and back-office plugins may still work in WordPress. Plugins that render forms, search, or checkout in a theme need a front-end integration. We review those dependencies before scoping the migration.

A WordPress block theme can be a better fit if your team depends heavily on theme plugins or wants one system to host and maintain. We can compare the two approaches using your site and publishing requirements.

Plan your WordPress build or migration

Share your current site and what your team publishes. We’ll help you map the editor, front end, and launch process.