@dornick/react
v0.1.0
Published
React bindings for Dornick — the in-browser agent SDK.
Downloads
17
Readme
@dornick/react
React bindings for Dornick — the in-browser agent SDK.
<DornickProvider> for transport context, <DornickForm> for the canonical form-replacement surface, useDornickHook for component-scoped subscriptions to Dornick's lifecycle events.
Install
npm i @dornick/react @dornick/coreReact 18+ is a peer dependency.
Use
import { useState } from "react";
import {
DornickProvider,
DornickForm,
useDornickHook,
type DornickFormHandle,
} from "@dornick/react";
import type { Dornick } from "@dornick/core";
import { BUILTIN_SKILLS } from "@dornick/skills";
import { signupConfig } from "./config";
function Signup() {
const [dornick, setDornick] = useState<Dornick | null>(null);
// Subscribe component-scoped — handler is auto-unsubscribed on unmount.
useDornickHook(dornick, "onComplete", ({ data }) => {
console.log("collected:", data);
});
return (
<DornickForm
config={signupConfig}
skills={BUILTIN_SKILLS}
onDornick={setDornick}
onComplete={(data) => save(data)}
>
<input name="email" />
<input name="company" />
<input name="team_size" />
</DornickForm>
);
}
export default function App() {
return (
<DornickProvider
transport={{
mode: "proxy",
url: "/api/dornick",
provider: "anthropic",
model: "claude-sonnet-4-6",
}}
>
<Signup />
</DornickProvider>
);
}useDornickHook is a Dornick | null-tolerant subscription — pass the instance once it's available (typically via <DornickForm onDornick={setDornick}>) and the hook attaches automatically. On unmount, the handler is detached.
Exports
| Symbol | What |
|---|---|
| <DornickProvider> | Context wrapper that carries a TransportOption. |
| <DornickForm> | Form surface; mounts a Dornick instance against the inner <form>. Forwards config, transport, skills, title, hideForm, onComplete, onError, onDornick. |
| useDornickHook(dornick, event, handler) | Subscribe to a Dornick lifecycle event from a React component. |
| useDornickContext() | Access the context value directly. |
| DornickFormHandle | Ref shape: { dornick, collect() }. |
Links
License
MIT — © Dipankar Sarkar
