2 min read
Data & Persistence
Prompts for saving, loading, and managing data in your app.
Saving Data (Web)
Persist to localStorage
Save [data] to localStorage so it persists between sessions. Load it when the page opens.
Handle empty state
If there's no saved data yet, show [default state] instead of a blank screen.
Auto-save
Add an auto-save feature — save to localStorage every time the user makes a change.
Export data
Let the user export their data as a JSON file they can download.
Import data
Let the user import data from a JSON file.
Saving Data (macOS/iOS)
Persist with UserDefaults
Save [data] using UserDefaults so it persists between launches.
Set up SwiftData
This data is too complex for UserDefaults. Set up SwiftData to store [model] with properties [list properties].
Auto-save on action
Save automatically when the user [action]. Load everything on app launch.
Reset to defaults
Add a 'Reset to defaults' option that clears saved data.
Working with Lists
Add items
Let the user add items to [list]. Each item should have [properties].
Reorder items
Let the user reorder [list] by dragging items.
Delete items
Let the user delete items from [list] with a [swipe/button/keyboard shortcut].
Search and filter
Add search/filter to [list]. Filter by [criteria].
Data Display
Display data
Show [data] as a [table/grid/list]. Each item should display [details].
Sort options
Sort [list] by [criteria]. Let the user switch between sort options.
Group by category
Group [items] by [category] with section headers.
Show summary
Show a count/summary at the top: '[X] items' or 'Total: [Y]'.
Tips
- localStorage is the simplest option for web — it stores strings, so Claude will JSON.stringify your data.
- UserDefaults works for simple settings on macOS/iOS.
- SwiftData is for structured data with multiple properties (like a list of habits with names, dates, streaks).
- Always handle the “first launch” case — what does the user see before they’ve added any data?