OneSignalSDKWorker.js) is a JavaScript file hosted on your server that is required for web push notifications. It enables your site to receive and display notifications, even when the user is not on your page.

How the OneSignal service worker processes push notifications
OneSignalSDKWorker.js in its sdk_files directory and configures the path for you. Do not upload the file to your site root or set a custom path in the dashboard or in code. See WordPress setup. Shopify also deploys the worker for you. See Shopify setup.Service worker setup
Create a dedicatedOneSignalSDKWorker.js file for OneSignal push notifications. If your site already has a service worker and you want to use a single file, see Combining multiple service workers instead.
Download or create OneSignalSDKWorker.js
OneSignalSDKWorker.js with the following single line of code:onesignalsdkworker.js, ossw.js). If you do, replace OneSignalSDKWorker.js in this guide with your filename.Upload to your web server
OneSignalSDKWorker.js on your server so it is publicly accessible over HTTPS. The file must not require authentication or login to access.Recommended: Host the file in a dedicated subdirectory that never serves pages, such as /push/onesignal/. This avoids conflicts with other service workers on your site (e.g., a PWA or AMP service worker) and keeps the URL path stable.- Example:
https://yoursite.com/push/onesignal/OneSignalSDKWorker.js
https://yoursite.com/OneSignalSDKWorker.js). You can upload the file to the root directory, but it may conflict with other service workers that need root scope. If you use a PWA, place OneSignalSDKWorker.js in a subdirectory instead.Verify the file is accessible
https://yoursite.com/push/onesignal/OneSignalSDKWorker.js). You should see the importScripts line from the first step:
Expected service worker file contents in the browser
Tell the SDK where to find the file
OneSignalSDKWorker.js at your site root (https://yoursite.com/OneSignalSDKWorker.js) unless you tell it a different location. How you tell it depends on your integration type.If you placed the file at your site root, no additional configuration is needed. Skip to the next step.If you placed the file in a subdirectory, you must set the path. Typical Site sets it in the dashboard. Custom Code sets it in OneSignal.init(). Mixing the two does not work: dashboard path fields do not apply to Custom Code, and serviceWorkerPath does not apply to Typical Site.Typical Site
Set the path in the OneSignal dashboard. Do not passserviceWorkerPath in code.- Go to Settings > Push & In-App > Web.
- Under Advanced Push Settings, enable Customize service worker paths and filenames.

Service worker path configuration in the dashboard
Custom Code
PassserviceWorkerPath and serviceWorkerParam in your OneSignal.init() call. Custom Code does not use the dashboard Customize service worker paths and filenames fields.https://yoursite.com/OneSignalSDKWorker.js and registration fails.See Custom Code setup to add these options to your full init snippet.Review service worker requirements
OneSignalSDKWorker.js file must meet all of the following requirements for push notifications to work.Web SDK setup
Combining multiple service workers
Each service worker file on your site is registered at a scope — a URL path that determines which pages it controls. Only one service worker can be active at a given scope. If you already have a service worker (for example, a PWA or caching worker) and want OneSignal to share the same file, you can combine them. To combine, add the OneSignalimportScripts line to your existing service worker file:
Migration guide
This section is for existing OneSignal customers who need to change the service worker file path, filename, or scope. Do not follow these steps unless you have a specific reason to change your current configuration.When and how to migrate your service worker
When and how to migrate your service worker
- The root-scope OneSignal service worker conflicts with a Progressive Web App (PWA)
- The service worker conflicts with AMP or another caching service worker
- Security policies prohibit third-party service worker code at root scope
OneSignalSDKWorker.js contains only:serviceWorkerParam (Custom Code) as described in Tell the SDK where to find the file. No other changes are needed.If your file contains OneSignal + other codeYour service worker may include additional importScripts calls (e.g., from following the combining multiple service workers guide). If your current setup still works, keep it as-is — splitting a merged service worker requires a two-phase rollout.If you must separate them:Add a retention comment to the existing file
importScripts line in your current service worker, add:Create a new dedicated OneSignal service worker
OneSignalSDKWorker.js in a subdirectory (e.g., /push/onesignal/) containing only:Update OneSignal configuration
OneSignal.init() (Custom Code) as described in Tell the SDK where to find the file.Wait for subscribers to migrate
Clean up
importScripts line from the original service worker file.Add a retention comment to the old file
Create the new file at the new location
OneSignalSDKWorker.js (or your chosen filename) in the new directory with:Update OneSignal configuration
Wait for subscribers to migrate
Clean up
FAQ
Does this guide apply to WordPress?
No. The WordPress plugin hosts and registersOneSignalSDKWorker.js in its sdk_files directory. Do not upload a worker to the site root or set serviceWorkerPath in code. See WordPress setup.
How do I set the service worker path for Typical Site vs Custom Code?
The Web SDK looks forOneSignalSDKWorker.js at your site root unless you set a custom path. Typical Site sets that path in the dashboard under Customize service worker paths and filenames. Custom Code sets it in code with serviceWorkerPath and serviceWorkerParam in OneSignal.init(). Dashboard path fields do not apply to Custom Code. See Tell the SDK where to find the file.
Why is my service worker returning a 404?
The file is not at the URL the SDK expects. Navigate to the full file URL in your browser to confirm it is accessible. If you placed the file in a subdirectory, the configured path must match the actual file location, including the directory and filename. Typical Site: check the dashboard path settings. Custom Code: checkserviceWorkerPath in OneSignal.init().
Why are notifications not displaying after I moved the service worker file?
Existing subscribers still reference the old service worker URL. The browser fetches the registered URL (cached up to 24 hours) each time a push arrives. If the old URL returns a 404, those subscribers do not receive notifications. Continue hosting the old file for at least one year while subscribers naturally migrate by revisiting your site. See the migration guide and Web push notifications not shown guide.Can I host the service worker on a CDN or subdomain?
No. Browsers require service workers to be served from the same origin as the page that registers them. The file must be on your primary domain — not a CDN, subdomain, or different domain.Why does my PWA conflict with the OneSignal service worker?
Both are likely registered at root scope (/) and only one service worker can be active at a given scope. Move the OneSignal service worker to a subdirectory scope (e.g., /push/onesignal/) so your PWA retains control of root scope, or combine them as described in Combining multiple service workers.
Can I rename the OneSignalSDKWorker.js file?
Yes. If your server requires a specific naming convention (e.g., all lowercase), rename the file to something likeonesignalsdkworker.js. Typical Site: update the Service worker filename field in the dashboard. Custom Code: update serviceWorkerPath in your OneSignal.init() call. See Tell the SDK where to find the file.
What content type should my server return for the service worker file?
The server must returnContent-Type: application/javascript; charset=utf-8. Some servers or CDN configurations return an incorrect MIME type, which causes the browser to reject the service worker registration.