Storage
Storage variables provide reactive access to all stored key-value pairs in your app's persistent storage system. This allows your custom blocks to read data that has been stored using storage actions or other app functionality.
Access in App Studio SDK
Tapcart.variables.storage
Properties
Property | Type | Description | Availability |
---|---|---|---|
storage | object | Object containing all stored key-value pairs | Always |
storage[key] | any | Value stored under a specific key | If key exists |
The storage object contains all key-value pairs that have been stored using storage actions. Keys can contain any serializable data types including strings, numbers, booleans, objects, and arrays.
Storage Actions Integration
The storage variable automatically reflects changes made through storage actions:
Available Storage Actions
storage/add
- Add or set a key-value pairstorage/update
- Update an existing key (same as add)storage/get
- Retrieve a specific key's valuestorage/remove
- Remove a specific keystorage/keys
- Get list of all storage keysstorage/clear
- Clear all stored data
Data Types & Serialization
Storage supports all JSON-serializable data types:
// Supported data types
const examples = {
string: variables.storage?.name, // "John Doe"
number: variables.storage?.age, // 25
boolean: variables.storage?.isActive, // true
object: variables.storage?.profile, // { name: "John", age: 25 }
array: variables.storage?.tags, // ["user", "premium"]
null: variables.storage?.optionalField // null
};
// Unsupported: functions, undefined, symbols, etc.
// These will be converted during serialization
Performance Considerations
The storage variable is optimized for performance:
- Reactive Updates: Only updates when storage actually changes
- Memoized Results: Prevents unnecessary re-renders
- Always Valid: Never null/undefined, always returns an object
Availability
Storage variables are always available and return a valid object, even when no data has been stored. An empty storage will return {}
.
Updated 9 days ago