Storage
Persistent key-value storage and web data management. The Storage module provides two capabilities: app-level key-value storage via Storage.app, and web data clearing via Storage.clearWebData().
Access: startiapp.Storage
For an introduction to how storage works in starti.app — see Storage and Data.
Properties
app: AppStorage
Persistent key-value storage using the native platform storage. Falls back to localStorage when used outside the app (e.g. on a regular website). All keys are internally namespaced with "startiapp:" to avoid collisions.
Important notes:
- All methods are asynchronous and return Promises.
- Data is stored as strings.
- Data is not encrypted — do not store secrets.
- Storage is local to the app installation and shared across all domains.
- Size limits: up to 256 KB per value, up to 50 MB total.
See AppStorage methods below for the full API.
Methods
clearWebData(): Promise<void>
Clears all web data stored by the app, including cookies, localStorage, and cache.
Example:
await startiapp.Storage.clearWebData();AppStorage Methods
All AppStorage methods are accessed through startiapp.Storage.app.
getItem(key: string): Promise<string | null>
Retrieves a value from storage.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
key | string | Yes | The key to retrieve. |
Returns: Promise<string | null> —The stored value, or null if the key does not exist or an error occurs.
Example:
const value = await startiapp.Storage.app.getItem("my-key");
if (value !== null) {
console.log("Found:", value);
}setItem(key: string, value: string): Promise<void>
Stores a value in storage. Overwrites any existing value for the same key.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
key | string | Yes | The key to store. |
value | string | Yes | The string value to store (max 256 KB). |
Example:
await startiapp.Storage.app.setItem("user-name", "John");
// Store JSON data by serializing it
await startiapp.Storage.app.setItem("settings", JSON.stringify({ theme: "dark" }));removeItem(key: string): Promise<void>
Removes a value from storage.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
key | string | Yes | The key to remove. |
Example:
await startiapp.Storage.app.removeItem("user-name");clear(): Promise<void>
Clears all app storage entries.
Example:
await startiapp.Storage.app.clear();isUsingNativeBridge(): boolean
Returns whether the native app storage bridge is being used, or whether the SDK has fallen back to localStorage. Useful for debugging.
Returns: boolean —true if using native storage, false if using the localStorage fallback.
Example:
if (startiapp.Storage.app.isUsingNativeBridge()) {
console.log("Using native storage");
} else {
console.log("Using localStorage fallback");
}Usage Patterns
Storing and retrieving JSON data
// Store an object
const settings = { theme: "dark", fontSize: 16 };
await startiapp.Storage.app.setItem("settings", JSON.stringify(settings));
// Retrieve and parse
const raw = await startiapp.Storage.app.getItem("settings");
if (raw) {
const parsed = JSON.parse(raw);
console.log(parsed.theme); // "dark"
}Checking for first launch
const hasLaunched = await startiapp.Storage.app.getItem("has-launched");
if (!hasLaunched) {
await startiapp.Storage.app.setItem("has-launched", "true");
// Show onboarding...
}Share
Share files and text through the native OS share sheet, or download files directly to the device.
User
Manage user identity within the app. Register a user ID to associate the current device with a known user, unregister on logout, and let users request account deletion. The user ID is persisted in localStorage so it survives page reloads.