Singleton hook
A single useGrist() handles all Grist states to avoid race conditions and code drift.
useGrist
A tiny, typed, batteries-included surface that turns the Grist plugin API into idiomatic React.
Compare with the raw plugin API Β· Testing without Grist
The hello-world demo is the whole idea in a handful of lines. The playground shell handles Grist setup; you only write:
import { useGrist, type UseGristOptions } from "grist-widget-sdk"
export const GRIST_OPTIONS: UseGristOptions = {
requiredAccess: "read table",
}
export function WidgetApp() {
const w = useGrist()
const rowKey =
w.record && typeof w.record.id === "number" ? String(w.record.id) : w.mode
if (w.mode === "empty") return <p>Select a row.</p>
if (w.mode === "new-row") return <p>New row flow</p>
return <p key={rowKey}>Selected row #{String(w.record!.id)}</p>
}Try it live Β· Source on GitHub
npx degit ArthurBlanchon/grist-widget-sdk/templates/grist-widget-template-vite my-widget
cd my-widget
pnpm install
pnpm devSee Getting started for templates, typing, and local testing.