Skip to content

datum

Local-first spatial sync for PostGIS.

What it looks like

ts
import { DatumClient } from 'datum-sync'

const db = await DatumClient.connect({
  serverUrl: 'ws://localhost:3000/ws',
  bbox: [-122.5, 37.7, -122.4, 37.8],
})

// Full PostGIS — runs locally in WASM, no network
const result = await db.query<{ name: string; area: number }>(`
  SELECT properties->>'name' AS name,
         ST_Area(geom::geography) AS area
  FROM features
  WHERE ST_Area(geom::geography) > 1000
`)

// Writes are captured automatically and synced in the background
await db.query(
  `INSERT INTO features (geom, properties, updated_at)
   VALUES (ST_SetSRID(ST_MakePoint($1, $2), 4326), $3::jsonb, now())`,
  [lng, lat, JSON.stringify({ name: 'Field site A' })]
)

Released under the MIT License.