Persisting UI State in Jetpack Compose with rememberSaveable: How, When, and What to Avoid
Learn how Jetpack Compose’s rememberSaveable keeps UI state across rotations and process death, the right way to use it, and the limits that can trip you up.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Learn how Jetpack Compose’s rememberSaveable keeps UI state across rotations and process death, the right way to use it, and the limits that can trip you up.
Learn how to lift state in Jetpack Compose, turning stateful components into reusable stateless ones. Understand the benefits, trade‑offs, and a concrete example with a search bar.
Learn when to use Jetpack Compose's remember versus rememberSaveable to keep UI state across rotations, with a concrete counter example, trade‑offs, and verification steps.
Reading LazyListState directly recomposes your UI on every scroll pixel. derivedStateOf limits recomposition to when the computed result actually changes — here's how it works and when it backfires.
Learn how to lift UI state into a ViewModel and wrap it with rememberSaveable so composables stay pure, survive rotation, and are easier to unit test.
Learn how to keep UI state (e.g., expanded/collapsed) of list items stable while scrolling and across configuration changes using LazyColumn item keys and rememberSaveable.
rememberSaveable removes onSaveInstanceState boilerplate in Jetpack Compose, but it serializes into a Bundle with strict size limits and no guarantee across process death. Learn when to use it, how to write custom Savers, and how to verify state actually survives rotation.
Use rememberSaveable to keep Compose UI state—text, toggles, lists—through device rotations without a ViewModel. Follow the step‑by‑step guide, verify with Layout Inspector, and know the limits.
Use remember with keys for cheap, eagerly computed derivations. Use derivedStateOf when the value depends on State objects and you want calculation deferred until the UI actually reads it—avoiding work during compositions where the derived value isn't needed.