Offline
Offline protocol schemas
Offline Strategy Schema
Determines how data is fetched when connectivity is limited.
Source: packages/spec/src/ui/offline.zod.ts
TypeScript Usage
import { ConflictResolution, EvictionPolicy, OfflineCacheConfig, OfflineConfig, OfflineStrategy, PersistStorage, SyncConfig } from '@objectstack/spec/ui';
import type { ConflictResolution, EvictionPolicy, OfflineCacheConfig, OfflineConfig, OfflineStrategy, PersistStorage, SyncConfig } from '@objectstack/spec/ui';
// Validate data
const result = ConflictResolution.parse(data);ConflictResolution
How to resolve conflicts when syncing offline changes
Allowed Values
client_winsserver_winsmanuallast_write_wins
EvictionPolicy
Cache eviction policy
Allowed Values
lrulfufifo
OfflineCacheConfig
Client-side offline cache configuration
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| maxSize | number | optional | Maximum cache size in bytes |
| ttl | number | optional | Time-to-live for cached entries in milliseconds |
| persistStorage | Enum<'indexeddb' | 'localstorage' | 'sqlite'> | ✅ | Storage backend |
| evictionPolicy | Enum<'lru' | 'lfu' | 'fifo'> | ✅ | Cache eviction policy when full |
OfflineConfig
Offline support configuration
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| enabled | boolean | ✅ | Enable offline support |
| strategy | Enum<'cache_first' | 'network_first' | 'stale_while_revalidate' | 'network_only' | 'cache_only'> | ✅ | Default offline fetch strategy |
| cache | Object | optional | Cache settings for offline data |
| sync | Object | optional | Sync settings for offline mutations |
| offlineIndicator | boolean | ✅ | Show a visual indicator when offline |
| offlineMessage | string | Object | optional | Customizable offline status message shown to users |
| queueMaxSize | number | optional | Maximum number of queued offline mutations |
OfflineStrategy
Data fetching strategy for offline/online transitions
Allowed Values
cache_firstnetwork_firststale_while_revalidatenetwork_onlycache_only
PersistStorage
Client-side storage backend for offline cache
Allowed Values
indexeddblocalstoragesqlite
SyncConfig
Offline-to-online synchronization configuration
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| strategy | Enum<'cache_first' | 'network_first' | 'stale_while_revalidate' | 'network_only' | 'cache_only'> | ✅ | Sync fetch strategy |
| conflictResolution | Enum<'client_wins' | 'server_wins' | 'manual' | 'last_write_wins'> | ✅ | Conflict resolution policy |
| retryInterval | number | optional | Retry interval in milliseconds between sync attempts |
| maxRetries | number | optional | Maximum number of sync retry attempts |
| batchSize | number | optional | Number of mutations to sync per batch |