> For the complete documentation index, see [llms.txt](https://docs.antsomi.com/developers-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.antsomi.com/developers-guide/website/web-push.md).

# Web Push

Empower your web application with Antsomi WebPush to deliver impactful notifications, fostering effective engagement and communication. Web push notifications offer a dynamic avenue for timely, personalized, and efficient information delivery, enhancing user interactions with your website.

To kickstart the integration of Antsomi WebPush, follow these steps to load the SDK asynchronously. This ensures optimal page load times and a seamless integration process.

### Initialization

Antsomi WebPush recommends loading `webpush.js` with the `async` flag so your page load times don't increase. To use it, place the following code *before* calling any other Antsomi WebPush functions.

{% tabs %}
{% tab title="HTML" %}

```html
<!-- CDP Web Insight script -->
<script src="https://st-a.cdp.asia/webpush.js" async></script>
<script>
  window.AntsomiPush = window.AntsomiPush || [];

  AntsomiPush.push(function() {
    AntsomiPush.init({
      portalId: <PORTAL_ID>, // Replace it with your Portal ID
    });
  });
</script>
```

{% endtab %}
{% endtabs %}

### Adding Service Worker

#### What are Service Workers?

Web Push Notifications, excluding Safari, require Service Worker files on your domain for subscription and notification reception. These files are downloaded upon accepting web notifications.

#### Integrating Antsomi WebPush Service Worker Files

1. **Download `sw.js` Files:** [link](https://drive.google.com/file/d/1InyiG3YeSBqysZcI9JxDB2YY3APfHqze/view?usp=sharing)
2. **Add Service Workers to the Website:** The `sw.js` file must be publicly accessible and can be placed at the top-level root of your site, e.g., <https://example.com/sw.js>.

<figure><img src="https://1976329911-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi16t4WMYZYowEFalUZLL%2Fuploads%2FZgnGJ2xBiYKyLks8ZFfl%2Fimage.png?alt=media&amp;token=ab77161a-3822-4083-9d48-5c784c4b4e02" alt=""><figcaption><p>Example of the URL: https://example.com/sw.js</p></figcaption></figure>
