API reference › @evolu/common › local‑first/Owner › deriveShardOwner

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

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

Derives a ShardOwner from an AppOwner using the specified path.

It derives from the AppOwner's OwnerEncryptionKey, not its OwnerSecret, so whoever holds that key, which also encrypts the AppOwner's local database, derives every ShardOwner, write key included. Keep the encryption key as secret as the mnemonic.

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