API reference / @evolu/common / Evolu/Owner / deriveShardOwner

Function: deriveShardOwner()

function deriveShardOwner(owner, path, transports?): ShardOwner;

Defined in: packages/common/src/Evolu/Owner.ts:299

Derives a ShardOwner from an AppOwner using the specified path.

Advantages of derived owners:

  • Deterministic: Same path always produces the same ShardOwner across all devices
  • Immediate availability: Can be hardcoded and used before sync occurs
  • Consistent setup: All devices start with identical data structure
  • Lifecycle management: Can implement epoch patterns for clean data deletion and recreation

Common patterns:

  • Use paths like ["shard", 1] for versioned data lifecycle
  • Use paths like ["project", "MyApp", 1] for named partitions with versions
  • Each device can derive the same owners and set up initial structure

Parameters

ParameterType
ownerAppOwner
pathreadonly [string | number, string | number]
transports?readonly WebSocketTransportConfig[]

Returns

ShardOwner

Was this page helpful?