A minimal SwiftUI sample app demonstrating how to integrate the Metabind SDK into an iOS application.
This project provides a starting point for building iOS apps with server-driven UI powered by Metabind. It shows the essential steps for initializing the Metabind client, displaying content, and handling navigation between pages.
- Xcode 15.0 or later
- iOS 17.0 or later
- A Metabind account with valid API credentials
- Clone or download this repository.
- Open
MetabindSampleRetail.xcodeprojin Xcode. - In
MetabindSampleRetailApp.swift, replace the placeholder values with your credentials from the Metabind dashboard:apiKeyorganizationIdprojectIdcontentId(for your root content page)
- Build and run the app on a simulator or device.
MetabindSampleRetail/
├── MetabindSampleRetailApp.swift # App entry point and main content view
└── Assets.xcassets/ # App icons and colors
The MetabindClient is initialized with your API credentials and injected into the SwiftUI environment:
@State var client = MetabindClient(
url: URL(string: "https://api.metabind.ai/graphql")!,
ws: URL(string: "wss://ws-api.metabind.ai")!,
apiKey: "your-api-key",
organizationId: "your-org-id",
projectId: "your-project-id"
)Use MetabindView to render content by its ID:
MetabindView(contentId: "your-content-id")Listen for metabind.content actions to navigate between content pages:
.onMetabindAction { action in
if action.name == "metabind.content",
let contentId = action.props["contentId"] as? String {
path.append(Destination.content(id: contentId))
}
}This sample code is provided for demonstration purposes.