compose-multiplatform-patterns

Implements Compose Multiplatform and Jetpack Compose patterns for state management, navigation, theming, and performance.

Updated Mar 18, 2026
One-click install
npx skills add https://github.com/freedom909/real-estate-saas --skill compose-multiplatform-patterns-freedom909
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: compose-multiplatform-patterns
Source: https://github.com/freedom909/real-estate-saas/tree/main/.trae/skills/compose-multiplatform-patterns
Command: npx skills add https://github.com/freedom909/real-estate-saas --skill compose-multiplatform-patterns-freedom909

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building shared UI across Android, iOS, Desktop, and Web with Compose Multiplatform involves recurring design decisions around state management, navigation, theming, and recomposition performance, and inconsistent patterns lead to buggy, hard-to-test composables. ## Core Features & Use Cases - State Management Patterns: Single-state-object ViewModels with StateFlow, lifecycle-aware collection via collectAsStateWithLifecycle, and sealed-interface event sinks for complex screens. - Type-Safe Navigation: Serializable route objects with Compose Navigation 2.8+, including dialog and bottom-sheet destinations. - Composable Design & Performance: Slot-based APIs, correct modifier ordering, @Stable/@Immutable types, keyed lazy lists, derivedStateOf, and allocation avoidance during recomposition. - Use Case: When building a KMP app screen that shares UI between Android and iOS, apply the ViewModel + single state object pattern with expect/actual platform composables to keep common code testable and platform behavior isolated. ## Quick Start Ask the AI to apply Compose Multiplatform patterns to build a stateless screen with a ViewModel, type-safe navigation route, and Material 3 theme for a KMP project.

Frequently Asked Questions about compose-multiplatform-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I manage UI state in Compose Multiplatform ViewModels?▼

Use a single immutable data class for screen state exposed as StateFlow from the ViewModel, and collect it in Compose with collectAsStateWithLifecycle. Update state via MutableStateFlow.update with copy() to keep emissions atomic and testable.

How to implement type-safe navigation in Jetpack Compose?▼

Define routes as @Serializable objects or data classes and register them with composable<Route> in a NavHost using Compose Navigation 2.8+. Retrieve arguments with backStackEntry.toRoute<Route>() instead of parsing string routes.

Does Compose Multiplatform support platform-specific UI on iOS and Android?▼

Yes, use expect/actual declarations for composables that need platform behavior, such as status bar styling. The commonMain expect composable is implemented per platform in androidMain and iosMain, with iOS handled via UIKit interop or Info.plist.

Why does my composable recompose too often?▼

Frequent recomposition usually comes from unstable parameter types, new object or lambda allocations in composable parameters, or reading state eagerly. Mark models @Immutable, use remember and derivedStateOf, and provide stable keys in lazy lists.

When should I use an event sink instead of callback lambdas in Compose?▼

Use a sealed interface event sink when a screen has many user actions, so the composable takes a single onEvent lambda instead of numerous callbacks. The ViewModel handles events in a when block, keeping the composable stateless and easy to preview.