Skip to Content
CrowCrow

Saved State & @CrowApp

Zero-key process-death persistence with saved(), saved back stacks, and zero-boilerplate Android entry points with @CrowApp and ProcessHost.

Android can kill your background process at any moment. Crow eliminates SavedStateHandle, manual Bundle keys, and boilerplate Activity/Application classes.

Zero-Key saved()

Replace signal(initial) with saved(initial) for any UI state that should survive configuration changes and OS process death:

@Ui
fun SearchScreen() {
    var query by saved("")
    var selectedCategory by saved("all")
    var recentSearches by saved(listOf("Kotlin", "Crow"))

    // Use them identically to signal() — compiled into fine-grained state
    // and automatically persisted to the saved-state Bundle.
}

crow-compiler synthesizes a stable, declaration-scoped key for every saved() call automatically — no hand-written string keys required. When mounting repeated stateful instances (such as inside a For loop or shared tab component), wrap each instance in savedKey("section") { ... } or use savedState("custom_key", initial).

Zero-Boilerplate Entry Point with @CrowApp

With the crow.app Gradle plugin, you annotate your root @Ui function with @CrowApp. Crow generates a zero-AndroidX CrowActivity and CrowApplication, wires edge-to-edge insets, predictive back, saved state, and your manifest <activity> automatically.

AppEntry.kt
@CrowApp(label = "Notes", process = NotesStore::class)
@Ui
fun NotesApp(@Once store: NotesStore) {
    NotesRoot(store = store)
}

Progressive Process Tiers

Choose exactly as much process control as your app needs:

TierHow you declare itWhat you get
Tier 1@CrowApp(label = "MyApp")Generated CrowActivity & manifest, zero boilerplate
Tier 2A@CrowApp(label = "MyApp", process = AppStore::class)Process-scoped object created once per OS process and injected into your root @Ui
Tier 2BStandalone @CrowApplicationCustom process bootstrap shared across Activities, Workers, and Services
Tier 3Subclass CrowApplication / CrowActivityFull manual hooks when integrating legacy Android SDKs

ProcessHost

Every @CrowApp exposes a ProcessHost with:

  • isForeground: Read<Boolean> — reactive foreground/background signal with zero AndroidX ProcessLifecycleOwner dependency.
  • isMainProcess & processName — zero-IPC process identity checks.
  • ProcessKey<T> — a thread-safe capability registry (getOrPut) for sharing stores, query clients, and platform services across your app.
  • TestAppHost & TestProcessHost — deterministic drop-in fakes for JVM unit tests.

For durable disk persistence of app data and preferences across cold kills, pair @CrowApp(process = ...) with crow-store.

How is this guide?

On this page