API reference@evolu/commonlocal‑first/Owner › deriveShardOwner

function deriveShardOwner(
  owner: AppOwner,
  path: readonly [string | number, string | number],
): ShardOwner;

Defined in: packages/common/src/local-first/Owner.ts:269

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