DEV Community

Subhendu Das
Subhendu Das

Posted on

PWA Enhancements in Herald: Marketing Automation for Devs

Problem

Indie developers often publish a stream of updates to their project repositories. Herald automatically drafts marketing copy and posts it to channels like Dev.to and Medium. Yet, once the content lands in a browser, the user experience can still be sluggish. Slow load times and lack of offline support mean that a freshly generated blog post may not be read immediately, reducing the impact of the marketing automation workflow.

How It Works

Herald adds a progressive‑web‑app (PWA) layer on top of its existing React front‑end. The PWA stack consists of three core pieces:

  1. Web App Manifest – a JSON file that describes the app’s appearance and launch behaviour.
  2. Service Worker – a script registered by the browser that intercepts network requests, caches assets, and enables offline use.
  3. Install Prompt – a UI that allows users to add the app to their home screen.

Manifest

Herald’s public/manifest.json looks like this:

{
  "name": "Herald – AI Marketing Automation",
  "short_name": "Herald",
  "start_url": "/",
  "display": "standalone",
  "theme_color": "#ffffff",
  "background_color": "#ffffff",
  "icons": [
    {
      "src": "/icons/icon-192.png",
      "sizes": "192x192",
      "type": "image/png"
    },
    {
      "src": "/icons/icon-512.png",
      "sizes": "512x512",
      "type": "image/png"
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

The display: "standalone" flag tells the browser to launch the page without the usual UI chrome, giving a native‑app feel.

Service Worker

The service worker is generated by Vite’s vite-plugin-pwa plugin, which bundles Workbox under the hood. A minimal src/sw.ts file might contain:

import { registerRoute } from "workbox-routing";
import { StaleWhileRevalidate } from "workbox-strategies";

registerRoute(
  ({ request }) => request.destination === "document",
  new StaleWhileRevalidate({ cacheName: "pages" })
);
Enter fullscreen mode Exit fullscreen mode

During the build step, Vite injects a precache manifest that lists all static assets. The service worker then serves these from cache on subsequent visits, cutting load times to a few hundred milliseconds.

Install Prompt

In the React component that renders the landing page, Herald listens for the beforeinstallprompt event and stores the event object so it can be fired later:

import { useEffect, useState } from "react";

export function InstallBanner() {
  const [deferredPrompt, setDeferredPrompt] = useState<Event | null>(null);

  useEffect(() => {
    const handler = (e: Event) => {
      e.preventDefault();
      setDeferredPrompt(e);
    };
    window.addEventListener("beforeinstallprompt", handler);
    return () => window.removeEventListener("beforeinstallprompt", handler);
  }, []);

  const install = () => {
    if (!deferredPrompt) return;
    (deferredPrompt as any).prompt();
    (deferredPrompt as any).userChoice.then(() => setDeferredPrompt(null));
  };

  return deferredPrompt ? (
    <button onClick={install}>Add Herald to Home Screen</button>
  ) : null;
}
Enter fullscreen mode Exit fullscreen mode

When the user taps the button, the browser shows the native install dialog, and the app is added to the device’s home screen.

Using It

Once the PWA files are committed, a standard npm run build produces a dist folder. Deploying this to a static host (Netlify, Vercel, or a custom CDN) automatically registers the service worker.

The user journey is simple:

  1. A developer pushes a commit that triggers Herald’s AI‑driven content generator.
  2. Herald posts the draft to Dev.to via the Dev.to API.
  3. The landing page for the new post is served as a PWA. The service worker caches the page and assets.
  4. The next time the developer visits the link, the page loads from cache and can be opened offline.
  5. The install banner invites the developer to add the app to their home screen, ensuring quick access to future content calendars.

Benefits to Marketing Automation

  • Reduced Latency – Cached assets mean the first load after a commit is often under 200 ms.
  • Offline Availability – A developer can read a freshly published blog post even without a network connection, keeping the marketing automation loop tight.
  • Higher Engagement – The install prompt nudges users to pin the app, leading to more frequent visits to the content calendar.
  • Consistency with Dev.to API – The PWA works seamlessly with Herald’s existing integration to Dev.to, Medium, and other channels.

By integrating PWA support, Herald extends its marketing automation capabilities beyond content creation into delivering a fast, app‑like experience that developers expect from modern web tools.

Future Directions

Herald’s PWA layer is a foundation for more advanced features, such as push notifications for new posts or background sync for queued drafts. These extensions would further tighten the feedback loop between code commits and marketing output, keeping the developer marketing cycle efficient and data‑driven.

Top comments (0)