OHMOHM Studio

React hooks

Drop-in mutation hooks for OHM extractions — @ohm_studio/sdk/react.

View as Markdown

Short name: OHM SDK · React  ·  Full import path: @ohm_studio/sdk/react

The hooks subentry of the OHM SDK (@ohm_studio/sdk). Tiny — no TanStack Query dependency, just useState + useCallback.

Setup

_app.tsx
import { OHM } from "@ohm_studio/sdk";
import { OhmProvider } from "@ohm_studio/sdk/react";

// OHM is hospital-deployed; point baseUrl at the hospital you're
// integrating with (api.ohm.doctor is OHM's demo hospital).
const ohm = new OHM({
  apiKey: import.meta.env.VITE_OHM_TEST_KEY!,
  baseUrl: import.meta.env.VITE_OHM_API_URL!,
});

export default function App({ children }) {
  return <OhmProvider client={ohm}>{children}</OhmProvider>;
}

Hooks

useOhmExtract({ apiSlug })

import { useOhmExtract } from "@ohm_studio/sdk/react";

function NoteForm() {
  const { mutateAsync, data, isPending, error } = useOhmExtract({
    apiSlug: "opd-clinic",
  });
  const onSubmit = async (text: string) => {
    const result = await mutateAsync({ text });
    console.log(result.data);
  };
  return (
    <button onClick={() => onSubmit(transcript)} disabled={isPending}>
      {isPending ? "Extracting..." : "Extract"}
    </button>
  );
}

useOhmAudioExtract({ apiSlug })

The most common hook — record audio in the browser, get back structured JSON.

const { mutate, data, isPending } = useOhmAudioExtract({ apiSlug: "opd-clinic" });
const onStop = (blob: Blob) => mutate({ file: blob });

useOhmSummarize()

const { mutateAsync } = useOhmSummarize();
const { summary } = await mutateAsync({ text, style: "patient" });

Hook return shape

{
  data:        T | null,
  error:       Error | null,
  isPending:   boolean,
  mutate:      (input) => void,        // fire-and-forget
  mutateAsync: (input) => Promise<T>,  // await the result
  reset:       () => void,
}

Composing with TanStack Query

The hooks are intentionally lightweight. If you'd rather use Query, drop them and wire the SDK directly:

import { useMutation } from "@tanstack/react-query";

const mutation = useMutation({
  mutationFn: (text: string) => ohm.extract({ apiSlug: "opd", text }),
});