Install
npm (recommended)
npm install onesygnal-web-sdkThe package has a default export only — there are no named exports (init, track,
etc. don’t exist as named imports, despite what older material may show).
import oneSygnal from 'onesygnal-web-sdk';
oneSygnal.init('YOUR_API_KEY', { apiUrl: 'https://sdk-api.1sygnal.app' });This injects a <script> tag pointing at the hosted bundle
(https://sdk.1sygnal.app/js/onesygnal.js) and queues calls until it loads — see
Configuration for what a pre-ready call returns.
Script tag (no npm)
Load the bundle directly and skip the loader package entirely:
<script
src="https://sdk.1sygnal.app/js/onesygnal.js"
data-api-key="YOUR_API_KEY"
data-api-url="https://sdk-api.1sygnal.app"
></script>Auto-init only fires if the script’s src contains the substring onesygnal and
data-api-url is present — a missing data-api-url silently skips auto-init with no
error. See Troubleshooting.
Loading the bundle directly gives you a different API surface than the npm loader —
e.g. init() returns Promise<void> here, void on the loader. See
API Reference.