HospifyDashboard
Docs menu

Web (TypeScript)

@hospify/org-sdk runs in any browser app (React, Vue, Angular, plain JavaScript) and on your server. Types are included.

npm install @hospify/org-sdk

Start it

TypeScript
import { Hospify, HospifyError } from "@hospify/org-sdk";

export const hospify = Hospify.start({
  publishableKey: import.meta.env.VITE_HOSPIFY_PUBLISHABLE_KEY,   // hpk_test_... or hpk_live_...
  getToken: async () => {
    const r = await fetch("/hospify/token", { method: "POST", credentials: "include" });
    return (await r.json()).token;                                  // from your server
  },
});

In the browser the SDK reads location with navigator.geolocation (the browser asks the agent the first time). Pass location: false to send none, or your own provider.

The SOS button

TypeScript
const off = hospify.sos.onUpdate((s) => {
  if (s.status === "acknowledged") show(`${s.responder} is on it`);
  if (s.outcome) show("Closed");
});

try {
  await hospify.sos.start({ note: "Need help" });
} catch (e) {
  if (e instanceof HospifyError) show(e.message);   // e.code: network_error, agent_inactive, ...
}

await hospify.sos.safe("Home now");      // or hospify.sos.cancel() for a mistake
await hospify.sos.resume();              // on page load: carry on with an SOS that's still open
hospify.stop();                          // on sign out
Browsers stop JavaScript in background tabs.For field agents on phones, use the React Native or Flutter SDK so location keeps flowing with the screen locked.

Options

OptionDefault
publishableKeyrequiredhpk_test_... or hpk_live_...
getTokenrequiredReturns the agent's session token from your server.
locationbrowserA provider with current() and optional watch(), or false.
locationEveryMs10000How often to send location while open.
pollEveryMs5000How often to check who's responding.
baseUrlapi.hospify.cloud