@onsetio/widget
v2.0.1
Published
Official Onset SDK for Widget Embed
Readme
Official Onset SDK for Widget Embed
We recommend that you should always be loaded the Widget.js script directly from https://widget.onset.io/widget.js, rather than including it in a bundle or host yourself. If must bundle the Widget code into your application, you can use this package.
Installation and Usage
Simply install the package:
npm install --save @onsetio/widget
yarn add @onsetio/widgetSetup and usage of these SDKs always follows the same principle.
import Widget from "@onsetio/widget";
const widgetInstance = new Widget({
page: "__PAGE_HOST__",
// ...
});Embed via CDN
<script>
window.onsetWidgetSettings = {
triggerText: "🔔 What's New",
page: "__PAGE_HOST__",
// ...
};
(function (e, t) {
e.onsetWidget = {};
e.onsetWidget.on = function () {
(e.onsetWidget.$ = e.onsetWidget.$ || []).push(arguments);
};
var c = t.getElementsByTagName("script")[0],
i = t.createElement("script");
i.async = true;
i.src = "https://widget.onset.io/widget.js";
c.parentNode.insertBefore(i, c);
})(window, document);
</script>