Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.metabind.ai/llms.txt

Use this file to discover all available pages before exploring further.

The Metabind Android SDK (metabind-android) lets you render server-driven content in your Kotlin applications. Build dynamic experiences that update instantly without app store releases.

View on GitHub

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

Requirements

RequirementVersion
Android8.0 (API 26) or later
UI toolkitJetpack Compose
JDK21

Installation

Add the SDK to your module’s dependencies. It pulls in bindjs-android (the Compose renderer) transitively.
dependencies {
    implementation("ai.metabind:metabind-android:0.0.10")
}
See the repository README for the Maven repository configuration.

Configure endpoints

The SDK reads the Metabind API endpoints from your AndroidManifest.xml as <meta-data> entries. Set both, or the client throws at startup:
<application>
    <meta-data
        android:name="ai.metabind.metabind.url"
        android:value="https://api.metabind.ai/graphql" />
    <meta-data
        android:name="ai.metabind.metabind.ws.url"
        android:value="wss://ws-api.metabind.ai" />
</application>

Quick start

Render content by its ID with the MetabindView composable. It fetches the content and its components, renders them as native Compose, and handles loading and error states:
import androidx.compose.runtime.Composable
import ai.metabind.metabind.view.MetabindView

@Composable
fun ContentScreen() {
    MetabindView(contentId = "your-content-id")
}
To receive live updates when the content changes in Metabind, opt in to the WebSocket subscription:
MetabindView(contentId = "your-content-id", enableSubscription = true)

Core concepts

MetabindView

MetabindView is the primary way to display content. Backed by MetabindViewModel, it:
  • Fetches the content and its required components
  • Renders the UI through the BindJS Compose runtime
  • Subscribes to real-time updates when enableSubscription is true
  • Exposes a StateFlow<UiState> of Loading | Success | Error
MetabindView(contentId = "content-id", enableSubscription = false)
Two focused variants ship alongside it:
  • PreviewView(contentId =) — a fixed-size (150×150 dp) live preview.
  • ThumbnailView(contentId =) — an offscreen-rendered bitmap snapshot, for non-interactive thumbnails.

ComponentRepository

For direct data access below the view layer, ComponentRepository.get(context) exposes the Apollo-backed fetchers and a dual-layer cache (10 MB in-memory chained to a SQLite store). It returns suspend functions and Kotlin Flows — for example getContentByToken(token) for a one-shot read and subscribeToPreviewByToken(token) for a live stream over WebSocket.

Real-time updates

For live content, either pass enableSubscription = true to MetabindView or subscribe directly through ComponentRepository. subscribeToPreviewByToken(token) returns a Flow that emits whenever the content changes in Metabind:
val repository = ComponentRepository.get(context)

repository.subscribeToPreviewByToken("your-content-id").collect { component ->
    // Re-render or update state with the new content
}
The client reconnects the WebSocket automatically, with backoff, if the connection drops. For cache-then-network delivery, watchPreviewByToken(token) returns a Flow<Result<PreviewComponent>>.

Direct GraphQL access

For data access below the view layer, ComponentRepository exposes suspend fetchers and Kotlin Flows over the same GraphQL API and cache. See the repository on GitHub for the available methods, and the GraphQL docs for the API itself.

Next steps

Build components

Create custom components for your app.

BindJS reference

Learn the component authoring language.

Managing content

Understand how to structure content.

iOS SDK

The iOS equivalent.