@digisreda/react
v0.1.0
Published
React wrapper (README §64) for the vanilla embeddable widget (@digisreda/widget) - <A11yWidget siteId="..." />.
Readme
@digisreda/react
React wrapper (README §64) around the vanilla embeddable widget
(@digisreda/widget) - one component instead of a raw <script> tag.
Install
npm install @digisreda/reactUsage
import { A11yWidget } from "@digisreda/react";
function App() {
return (
<>
{/* ...your app... */}
<A11yWidget siteId="your-site-public-id" />
</>
);
}siteId is the Site's public_id (a UUID) from the dashboard's widget
settings page - not the numeric site id.
Renders nothing itself (null) - it injects the same
<script data-site="..." data-api="..."> tag the plain HTML embed
snippet uses, so there's exactly one widget implementation to keep
working, not a React reimplementation that could drift from it.
Self-hosted deployments
<A11yWidget
siteId="your-site-public-id"
widgetUrl="https://your-domain.ru/static/widget.js"
apiUrl="https://your-domain.ru"
/>Limitations
The underlying vanilla widget has no destroy()/cleanup API - unmounting
<A11yWidget /> removes the <script> tag it injected, but not whatever
the widget already mounted onto document.body (its toolbar, etc.) before
unmount. In practice this only matters if you're conditionally mounting
and unmounting the widget within a single page session, which isn't the
typical use case (most sites mount it once, for the page's lifetime).
