@onsetio/widget
v0.2.2
Published
Official Onset SDK for Widget Embed
Downloads
75
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/widget
Setup 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>