Skip to content
Dashboard

Building a powerful notification system for Vercel with Knock

, Aaron Morris

How to create realtime alerting and communication system using a best-of-breed solution

Link to headingThe case for Knock

const { Knock } = require("@knocklabs/node");
const knock = new Knock(process.env.KNOCK_API_KEY);
await knock.workflows.trigger("new-comment", {
recipients: ["1", "2"],
// optional
data: { "project_name": "My Project" },
actor: "3",
cancellationKey: "cancel_123",
tenant: "jurassic_world_employees"
});

Workflows are triggered via a call to the trigger endpoint, which tells Knock to run a specified payload of recipients and data through the workflow specified by the call.

Link to headingUsing Knock at Vercel

import { KnockFeedProvider } from "@knocklabs/react-notification-feed";
// We'll write this next
import NotificationToaster from "./NotificationToaster";
const NotificationToastProducer = () => {
// An example of fetching the current authenticated user
const { user } = useCurrentUser();
return (
<KnockFeedProvider
apiKey={process.env.KNOCK_PUBLIC_API_KEY}
feedId={process.env.KNOCK_FEED_CHANNEL_ID}
userId={user.id}
>
<NotificationToaster />
</KnockFeedProvider>
);
};

Knock's React Component library makes setting up new components simple. We're able to maintain control over the code, while still leveraging a powerful notification tool in the backend.

Knock allows you to build cross-channel notifications with easy-to-use workflows.
Knock allows you to build cross-channel notifications with easy-to-use workflows.
Knock provides a single API for all of your notifications code and observability tools so you can understand how your notifications are sent.
Knock provides a single API for all of your notifications code and observability tools so you can understand how your notifications are sent.

Link to headingUpdated notifications for your Vercel workflow

Link to headingGet Started