Integrations
Web push for any HTML site, React, Next.js or static host
If you control your files, setup is one script tag and one file in the folder your host serves as the site root.
If you deploy your own files, setup is two things: put superwicket-sw.js where your host serves the site root, and load the script on every page.
Setup
- Add the service worker file to the folder that maps to your domain root:
The file is one line:
Stack Folder Plain HTML, PHP, Jekyll The site root, next to index.htmlNext.js, Vite, React (CRA), Vue, Nuxt 3, Astro, Remix public/SvelteKit, Gatsby, Hugo static/Angular public/(v17+) or listed inassetsin angular.jsonRails public/Laravel public/Django Serve it from a view or web server rule at /superwicket-sw.jsimportScripts('https://superwicket.com/p/sw/YOUR_PIXEL_KEY.js'); - Load the script on every page, in your base template or layout:
In Next.js (App Router), put it in<script async src="https://superwicket.com/p/YOUR_PIXEL_KEY.js"></script>app/layout.tsx:import Script from 'next/script'; export default function RootLayout({ children }) { return ( <html lang="en"> <body> {children} <Script src="https://superwicket.com/p/YOUR_PIXEL_KEY.js" strategy="afterInteractive" /> </body> </html> ); } - Deploy and check that
https://your-site.com/superwicket-sw.jsreturns the JavaScript line with a JavaScript content type. Netlify, Vercel, Cloudflare Pages and GitHub Pages do this by default for.jsfiles. - Send events from your app to trigger flows or segment subscribers:
If you need to call it before the script loads, push calls onto a queue:// after the script has loaded window.superwicket.track('report_exported', { rows: 1200 }); window.superwicket.setParams({ plan: 'trial', account_id: 'acct_42' });(window.superwicket = window.superwicket || []).push(['track', 'signup']);
Single-page apps
Load the script once in the app shell. It records page views on client-side route changes too (it listens to history.pushState and popstate), so page-view triggers and segments work in React, Vue and Svelte apps without extra code.
If you already have a service worker
A page can have only one service worker per scope. If you use Workbox, next-pwa or your own worker for offline caching, don’t add a second file. Add the importScripts line to your existing worker and set SuperWicket’s service worker path to that file in the website settings.
Your own subscribe button
Instead of a widget, give any element the data-superwicket-subscribe attribute, or call window.superwicket.subscribe() from your own click handler. The browser permission prompt must follow a click, so don’t call it on page load.
From your backend
On Pro and above, the REST API sends a notification to one subscriber (looked up by a custom field such as your user ID), records server-side events, and manages campaigns and segments. See web push for SaaS.
Frequently asked questions
Where does the service worker go in Next.js?
In the public/ folder. Next.js serves public/superwicket-sw.js at /superwicket-sw.js.
Will it clash with my existing service worker?
A page can have only one service worker per scope. If you already have one (for a PWA or offline caching), add the importScripts line to it and set SuperWicket to use that path.
Try it on your own site
The Free plan has no time limit and needs no card. Add one script tag, or share a hosted subscribe page if you can’t upload files.