---
title: Offline
description: Offline protocol schemas
---

{/* ⚠️  AUTO-GENERATED — DO NOT EDIT. Run build-docs.ts to regenerate. Hand-written docs go in content/docs/guides/. */}

Offline Strategy Schema

Determines how data is fetched when connectivity is limited.

<Callout type="info">
**Source:** `packages/spec/src/ui/offline.zod.ts`
</Callout>

## TypeScript Usage

```typescript
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_wins`
* `server_wins`
* `manual`
* `last_write_wins`


---

## EvictionPolicy

Cache eviction policy

### Allowed Values

* `lru`
* `lfu`
* `fifo`


---

## 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` | 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_first`
* `network_first`
* `stale_while_revalidate`
* `network_only`
* `cache_only`


---

## PersistStorage

Client-side storage backend for offline cache

### Allowed Values

* `indexeddb`
* `localstorage`
* `sqlite`


---

## 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 |


---

