Skip to main content
The Metabind iOS content SDK is the MetabindContent library in the metabind-apple Swift package. It fetches content from Metabind and renders it as native SwiftUI, so you can update layouts and experiences over the air without an App Store release.

View on GitHub

metabind-apple — source code, issues, and releases.

Requirements

Installation

Add the metabind-apple package to your project using Swift Package Manager, and choose the MetabindContent library. The package ships two other libraries — MetabindAI and MCPAppsHost, for embedding a governed agent in your app — that you don’t need for content rendering.
  1. Open your project in Xcode
  2. Go to File → Add Package Dependencies
  3. Enter the repository URL:
  1. Select the version, then add the MetabindContent library to your target

Quick start

1. Initialize the client

Create a MetabindClient with your API credentials from the Metabind dashboard:

2. Display content

Use MetabindView to render content by its ID:
To receive live updates when the content changes in Metabind, opt in to the WebSocket subscription:

3. Handle actions

Listen for actions triggered by user interactions:

Core concepts

MetabindClient

The client manages the connection to Metabind’s API and handles:
  • Authentication — API key validation and request signing
  • Content fetching — GraphQL queries for content and components
  • Real-time updates — WebSocket subscriptions for live content changes
  • Caching — a local SQLite-backed cache of fetched content and components
Inject the client into the SwiftUI environment so all views can access it:
For direct access, MetabindClient exposes async fetchers — fetchContent(id:), fetchContents(typeId:limit:) — along with streamContent(id:) and subscribeToContent(id:) for cache-then-network and real-time streams.

MetabindView

MetabindView is the primary way to display content. It automatically:
  • Fetches the content and its required components
  • Renders the UI based on your design system
  • Subscribes to real-time updates when enableSubscription is true
  • Handles loading and error states

Actions

Actions are events triggered by user interactions with your content. Handle them with the onMetabindAction modifier, which delivers a MetabindContentAction (a name and a props dictionary): An action’s name is whatever string the component author emits — there’s no fixed platform vocabulary. One convention the Metabind samples use:

Real-time updates

For live content, either pass enableSubscription: true to MetabindView or subscribe directly. subscribeToContent(id:) opens a GraphQL WebSocket subscription and yields the content each time it changes in Metabind:
The client pauses the subscription when the app enters the background and resumes it on return. For cache-then-network delivery without a live subscription, use streamContent(id:).

Direct GraphQL access

Beyond MetabindView, MetabindClient exposes the underlying GraphQL operations directly, all following the same shape:
  • fetch* — a single async request.
  • stream* — an AsyncStream that yields cached data first, then network updates.
  • subscribeTo* — a real-time WebSocket subscription (content only).
These cover content, components, content types, assets, tags, packages, and saved searches. For the full method catalog and parameters, see the client API reference in the repository README; for the GraphQL API itself, see the GraphQL docs. For apps with multiple content pages, integrate with SwiftUI’s navigation system:

Platform support

Next steps

Sample app

See a complete example of the SDK in action.

Build components

Create custom components for your app.

BindJS reference

Learn the component authoring language.

Managing content

Understand how to structure content.