@spacefast/wordpress
v0.0.23
Published
Read-only WordPress REST client for Spacefast data sources.
Downloads
682
Readme
@spacefast/wordpress
Private-beta, read-only access to WordPress content from a Spacefast site or any
JavaScript app with fetch.
Set up a Spacefast site
- In the Dashboard, open your space, go to Settings → Data sources, add a
named public WordPress site, choose the default source, and save. The site
must expose standard pretty-permalink REST URLs under
/wp-json; Dashboard sources do not support?rest_route=...URLs. - Connect the repository that builds the site to the same space.
- Install the SDK in that repository:
npm install @spacefast/wordpress- Read content in build-time or SSR Node code. Omit
urlfor the default source, or passsourceto select another configured name:
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");
const docs = createWordPressClient({ source: "docs" });- Commit the dependency and code, then start a new Spacefast repository build. Each build receives the Dashboard source configuration and fetches the current WordPress content.
- Back in Settings → Data sources, choose Connect WordPress. Download the plugin, install it in WordPress, and paste the one-time connection into Settings → Spacefast. Test the connection. Public content changes now coalesce into safe, automatic production builds; Build now remains available in both WordPress and the Spacefast Dashboard.
URL and environment rules
Zero-config discovery reads Node environment variables, so it only works during
a build or in an SSR Node runtime. Browser code must pass an explicit url.
Explicit URLs may be a WordPress site URL, a /wp-json or /wp-json/wp/v2
REST root, or a supported non-pretty form such as
https://blog.example.com/index.php?rest_route=/.
An explicit SDK url always wins. With source, the client resolves only that
named entry from SPACEFAST_DATA_SOURCES (or legacy SPACEFAST_DATASOURCES)
and ignores WORDPRESS_URL. Without source, a non-blank WORDPRESS_URL
wins; otherwise the payload's default entry is used. Spacefast preserves
user-defined build variables instead of replacing them with Dashboard-generated
values.
Private beta boundaries
- Read-only: the client only makes
GETrequests. It does not create, edit, or delete WordPress content. - Public content only: there is no authentication, preview, draft, or private content support.
- Build snapshots: WordPress changes become visible only after a repository build succeeds. The optional Spacefast WordPress plugin starts that build automatically; without it, use Build now.
- Controlled credential: the private-beta plugin gets a one-time API key
restricted to this Space and only the
builds:triggerpermission. The trigger derives the production repository, saved commands, and live target server-side; the plugin cannot upload arbitrary output or override a build. Revoke the key from Developer settings if the WordPress installation is retired or compromised. - Private beta: the API may change before the stable release.
