state-restoration

Generate SwiftUI state restoration infrastructure for navigation paths, tabs, scroll positions, and form drafts.

Updated Mar 1, 2026
One-click install
npx skills add https://github.com/mazicimert/RunDom --skill state-restoration-mazicimert
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: state-restoration
Source: https://github.com/mazicimert/RunDom/tree/main/.claude/skills/generators/state-restoration
Command: npx skills add https://github.com/mazicimert/RunDom --skill state-restoration-mazicimert

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Generates state preservation and restoration infrastructure for navigation paths, tab selection, scroll positions, and form data across app launches and background termination. Use when user wants to save/restore app state, remember where the user left off, or persist UI state.

Core Features & Use Cases

  • Provides a Codable AppState model and a central StateRestorationManager to automate saving and restoring across App lifecycle events.
  • Offers optional modifiers for navigation path, scroll position, tab selection, and form drafts to cover common UI state persistence scenarios.
  • Supports both file-based persistence and UserDefaults with migration-friendly state versions for forward compatibility.

Quick Start

Enable automated state restoration by configuring the generator to track navigation, tabs, scrolls, and form drafts, then integrate the generated code into your app.

Frequently Asked Questions about state-restoration

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

FAQPage Schema
How do I persist navigation paths and scroll positions in SwiftUI across app launches?

To persist navigation paths and scroll positions in SwiftUI, you need a state restoration infrastructure that saves UI state to a Codable model during background termination and restores it on launch. This requires a manager to automate saving and restoring across App lifecycle events.

Can I use UserDefaults to save SwiftUI app state like tab selections and form drafts?

Yes, you can use UserDefaults to save SwiftUI app state like tab selections and form drafts. State restoration infrastructure supports both file-based persistence and UserDefaults, allowing you to store a Codable AppState model to remember where the user left off.

What's the best way to remember where a user left off in a NavigationStack app?

The best way to remember where a user left off in a NavigationStack app is to implement a StateRestorationManager that tracks navigation paths. It applies optional modifiers to automate debounced autosaving, ensuring the UI state persists across background termination and launches.

Does state restoration work with SwiftUI TabView and ScrollView simultaneously?

Yes, state restoration works with SwiftUI TabView and ScrollView simultaneously. The infrastructure provides optional modifiers specifically designed to track and persist tab selections and scroll positions alongside navigation paths, covering common UI state persistence scenarios in one model.

How do I handle state migrations when updating my SwiftUI app's persisted state?

To handle state migrations when updating your SwiftUI app's persisted state, use migration-friendly state versions. The Codable AppState model supports versioning for forward compatibility, ensuring existing users experience seamless state restoration when you release app updates.

Why do I lose form drafts when my SwiftUI app is terminated in the background?

You lose form drafts when your SwiftUI app is terminated in the background because the app lacks automated state preservation. Implementing a StateRestorationManager with debounced autosave and background save capabilities ensures form data persists across background termination.