← Back to docs

Location SDK

Build Uber-like live location streams.

Use DomVia Realtime location patterns for trips, delivery drivers, inspectors, couriers, service providers, and same-day movement visibility.

Package

@domvia/realtime-location

install

npm install @domvia/realtime @domvia/realtime-location

@domvia/realtime-location

Built for focused realtime use cases.

Keep the SDK modular, documented, and safe to extend as new products are added.

Architecture

How this guide should be used.

Step 01

Start tracking only during an active job

Location streams should begin when a trip, inspection, delivery, or field session starts, then stop when the session ends.

Step 02

Throttle updates before they hit your server

Send controlled coordinate updates instead of every GPS tick. This protects battery, bandwidth, rate limits, and gateway usage.

Step 03

Use private channels for viewers

Only authorized customers, operators, drivers, or support staff should receive a live location stream.

Step 04

Expire same-day visibility

Uber-like tracking should not become permanent surveillance. Store only what the product needs after the job is complete.

Examples

Focused implementation notes.

Client location viewer

Subscribe to a private location stream and update the map when new coordinates arrive.

Client location viewer

import { DomViaRealtime } from "@domvia/realtime";
import {
  buildLocationChannelName,
  createLocationStream,
} from "@domvia/realtime-location";

const realtime = DomViaRealtime.create({
  key: "pk_live_your_public_key",
  host: "ws.domvia.net",
  authEndpoint: "/realtime/auth",
});

const channelName = buildLocationChannelName({
  channelKind: "private",
  purpose: "delivery",
  subjectType: "driver",
  subjectId: "driver-44",
  sessionId: "day-2026-05-26",
});

const stream = createLocationStream(realtime, {
  channelName,
});

stream.onLocation((event) => {
  map.moveMarker(event.subject_id, {
    lat: event.lat,
    lng: event.lng,
  });
});

Reporter with throttling

Use the reporter on mobile or driver-side flows before sending location to your trusted server.

Reporter with throttling

import { createLocationReporter } from "@domvia/realtime-location";

const reporter = createLocationReporter({
  minIntervalMs: 3000,
  idleIntervalMs: 15000,
  submit: async (sample) => {
    await fetch("/api/location/report", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify(sample),
    });
  },
});

await reporter.report({
  subject_id: "driver-44",
  lat: 40.8518,
  lng: 14.2681,
  accuracy: 9,
  speed: 4.2,
  session_id: "day-2026-05-26",
});

Safety

Rules before production traffic.

Use private channels for live location streams.

Stop tracking immediately when the trip or job ends.

Throttle updates to a predictable interval.

Do not use E2EE by default for location unless the product requires encrypted coordinates.

Keep location retention short and explain visibility clearly in the product UI.

Continue

Keep reading without crowding the main docs page.