Skip to content
Spacefast Docs
Esc
navigateopen⌘Jpreview
On this page

WordPress

Build a Spacefast site from public WordPress content with the read-only WordPress client.

The @spacefast/wordpress client reads public WordPress content during your repository build, so the build can render posts and pages into a static Spacefast site.

Connect a source

In the Spacefast dashboard, open the space, go to Settings → Data sources, and add a named public WordPress site as the default source. Then connect the repository that builds the site to the same space.

Install the client in that repository:

npm install @spacefast/wordpress
pnpm add @spacefast/wordpress
yarn add @spacefast/wordpress
bun add @spacefast/wordpress

Read content during the repository build:

import { createWordPressClient } from "@spacefast/wordpress";

const wp = createWordPressClient();
const { data: posts, pagination } = await wp.posts.list({
  perPage: 10,
  orderBy: "date",
});
const about = await wp.pages.bySlug("about");

Collections include posts, pages, media, categories, tags, and users. The client preserves WordPress pagination metadata.

Multiple sources

A space can hold several named WordPress sources. Omit url to use the default source, or select another configured source by name:

const docs = createWordPressClient({ source: "docs" });

Repository builds receive SPACEFAST_DATA_SOURCES and WORDPRESS_URL from the dashboard configuration. This zero-config discovery reads Node environment variables, so use it in build-time or SSR code, not in a browser bundle. An explicit url overrides the discovered configuration. Pass a url for local development or browser code:

const local = createWordPressClient({ url: "https://example.wordpress.com" });

Rebuild on WordPress changes

Install the Spacefast plugin in WordPress. In WordPress Settings → Spacefast, choose Headless CMS, continue to Spacefast, authorize one team on the consent screen, and select the space. The consent screen requires space management (spaces:write). You cannot remove that scope.

Public content changes then wait for a 60-second quiet window before one production build starts. Build now is immediate, in both the WordPress plugin and the Spacefast dashboard.

The plugin authenticates with OAuth 2 and PKCE. Access is bounded by the signed-in user’s live team role, the one team approved on the consent screen, and the Headless CMS scope (builds:trigger plus team and space discovery). Disconnect in the plugin revokes refresh access. The team’s Connected Apps page revokes the grant immediately.

The plugin also has a Static WordPress mode: it publishes a Simply-Static-generated copy of the WordPress site directly to the space, under the spaces:publish scope, with no repository build involved.

Boundaries

  • The client makes GET requests only. It cannot edit WordPress content.
  • The client does not support draft, preview, private, or authenticated WordPress content.
  • Content is a build snapshot. It changes on the Spacefast site only after a new repository build succeeds.
  • Dashboard sources require standard pretty-permalink REST URLs under /wp-json. Explicit client URLs can also point at the REST root itself.

Last updated on August 19, 2026

Was this page helpful?