Core SDK
Web push (React)
useWebPush hook for browser push notifications.
useWebPush registers the browser Push API with the Worker VAPID keys and keeps subscriptions in sync.
import { useWebPush } from "@fluxy-chat/react";
function PushToggle({ client }: { client: FluxyChatClient }) {
const {
permission,
subscriptions,
isLoading,
requestPermissionAndSubscribe,
unsubscribe,
} = useWebPush(client, { projectId: "default" });
if (permission === "unsupported") {
return <p>Push not supported in this browser.</p>;
}
return (
<button
disabled={isLoading}
onClick={() =>
subscriptions.length
? unsubscribe()
: requestPermissionAndSubscribe()
}
>
{subscriptions.length ? "Disable push" : "Enable push"}
</button>
);
}Requirements
- Service worker at
/sw.js(or customswPath) that handlespushevents. - Worker VAPID keys — auto-generated per project on first request.
- Member JWT on the client.
Server-side delivery
The Worker sends push on offline paths (mentions, digests). Configure preferences with PATCH /digest/preferences (webPushEnabled).
See Web Push (VAPID) guide for HTTP routes and manual subscription flow.