Skip to content

RFC: Use WordPress as your app's data store #817

Closed

Description

@josephfusco

Idea

Headless Documents gives your app a database, using the WordPress site you already have. Turn on a small opt-in plugin, save JSON from your app, and never silently lose a write.

flowchart TD
  App["Your app"] -->|REST or GraphQL| WP["Plugin<br/>checks version"]
  WP --> T[("wp_headless_<br/>documents")]
  Admin["wp-admin<br/>Tools screen"] -.->|read-only| T
Loading

Why

  • You don't need a second database like Firebase or Supabase, or a custom plugin.
  • Normal WordPress and WPGraphQL saves let the last write win. Headless Documents rejects a stale write with a 409.
  • Site owners can see the data in wp-admin, and WordPress users and roles control access.

Decided

  • Documents live in one dedicated table, grouped into collections like Firestore. History can be added later without migrating data.

  • REST and WPGraphQL can both get, update, delete, list and add documents, with the same version check.

  • Collections are admin-only until you register them. Registering a collection sets its access mode and a JSON Schema that WordPress validates, which is how a form or waitlist accepts public writes:

    register_headless_collection( 'waitlist', array(
    	'access' => 'public-create', // or 'admin' (default) or 'owner'
    	'schema' => array( 'type' => 'object', 'required' => array( 'email' ) ),
    ) );
  • A JS client for app servers would look roughly like this:

    const ref = store.collection('preferences').doc('user-42');
    await ref.update((d) => ({ ...d, theme: 'dark' })); // retries on conflict

Plan

  1. Storage and REST, as a standalone plugin (prototyped in FaustWP in feat(faustwp): add an opt-in versioned document store with conflict detection faustjs#2674).
  2. register_headless_collection with access modes and schemas.
  3. WPGraphQL support.
  4. The JS client.

Realtime, complex queries and high write volume are out of scope.

Activity

  1. pinned this issue on Oct 20, 2026
  2. josephfusco commented on Oct 20, 2026

    @josephfusco
    MemberAuthor

    Decided: dedicated tables. wpengine/faustjs#2674 now stores documents in wp_faustwp_documents with a unique key on collection, owner and slug, so creates and conditional updates can't lose writes. History and per-user documents can be added later without migrating data.

  3. josephfusco commented on Oct 27, 2026

    @josephfusco
    MemberAuthor

    Closing as accepted and shipped: plugins/hwp-documents released 1.0.0 with a dedicated hwp_documents table, versioned compare-and-swap writes (409 Conflict on stale updates), and a REST API. GraphQL support can be tracked separately if needed.

  4. moved this from 🆕 Backlog to ✅ Closed in Headless OSSon Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs DiscussionAnything that needs a discussion/agreement[Area] DocumentsIssues for the headless documents plugin[Type] FeatureA new feature within an existing module

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions