Overview
This sample project provides a starting point for building iOS apps with server-driven UI powered by Metabind. It demonstrates:- Initializing a
MetabindClientwith your API credentials - Injecting the client into the SwiftUI environment
- Displaying content using
MetabindView - Handling navigation actions between content pages
Download Sample
Get the complete Xcode project from GitHub.
Requirements
| Requirement | Version |
|---|---|
| Xcode | 15.0 or later |
| iOS | 17.0 or later |
| Metabind account | Create one here |
Configure the sample
Add your credentials
In
MetabindSampleRetailApp.swift, replace the placeholder values with your credentials from the Metabind dashboard:apiKey— Your project’s API keyorganizationId— Your organization identifierprojectId— Your project identifiercontentId— The ID of your root content page
Initialize the client
TheMetabindClient connects your app to the Metabind API. Initialize it with your credentials and inject it into the SwiftUI environment:
- GraphQL API (
api.metabind.ai) — For fetching content and components - WebSocket API (
ws-api.metabind.ai) — For real-time updates when content changes
Display content
UseMetabindView to render content by its ID. The view automatically fetches and displays the content defined in your Metabind project:
MetabindView handles:
- Fetching the content and its associated components
- Rendering the UI based on your design system
- Subscribing to real-time updates for live content changes
Handle navigation
Content can contain actions that navigate to other pages. Listen for themetabind.content action to handle navigation between content pages:
onMetabindAction modifier receives actions triggered by user interactions with your content. The metabind.content action is built-in and includes the target content ID in its properties.