@disclosed/widget
v0.1.0
Published
Headless SDK for Disclosed — render your own AI-disclosure UI while Disclosed supplies the wording and logs a tamper-evident record.
Maintainers
Readme
@disclosed/widget
Headless SDK for Disclosed — render your own AI-disclosure UI while Disclosed supplies the wording and logs a tamper-evident record that it was shown (EU AI Act Article 50 + US bot-disclosure laws).
You own the markup. Disclosed owns the disclosure text and the logged render — that's what keeps the compliance evidence valid, so there is no API to change the wording.
React
npm install @disclosed/widgetDrop-in component
The fastest path — render it near your chat and you're compliant. It shows the canonical notice, handles acknowledgement, and logs the verified render itself:
import { Disclosure } from "@disclosed/widget/react";
<Disclosure siteKey="site_live_xxxx" />Style it with className or style; it ships legible defaults out of the box.
Custom UI (useDisclosure)
For full control over the markup, use the hook and render your own element:
import { useDisclosure } from "@disclosed/widget/react";
export function AiDisclosure() {
const { content, ref, acknowledge } = useDisclosure({ siteKey: "site_live_xxxx" });
if (!content) return null;
return (
<div ref={ref} className="my-disclosure">
{content.notice}
{content.requireAck && <button onClick={acknowledge}>OK</button>}
</div>
);
}Attach ref to the element that contains content.notice. Disclosed verifies
it's visible and legible, then logs the render. The hook is SSR-safe and re-logs
once per page view.
Vanilla JS
import { createDisclosure } from "@disclosed/widget";
const d = await createDisclosure({ siteKey: "site_live_xxxx" });
d?.ready((content) => {
const el = document.querySelector("#ai-disclosure")!;
el.textContent = content.notice;
d.observe(el);
});Get your site key from the Disclosed dashboard (open a chatbot → Install snippet → Headless SDK). Brand color, position, theme, and languages are configured in the dashboard, not in code.
Local development
By default the SDK loads from the Disclosed CDN. To test against a local or
staging deployment, pass scriptUrl (accepted by <Disclosure>,
useDisclosure, and createDisclosure):
<Disclosure siteKey="site_live_xxxx" scriptUrl="http://localhost:3177/widget-headless.js" />