Setup
To use the notifications package, you need to add the required environment variables to your project, as specified in thepackages/notifications/keys.ts
file.
In-app notifications feed
To render an in-app notifications feed, import theNotificationsTrigger
component from the @repo/notifications
package and use it in your app. We’ve already added this to the sidebar in the example app:
apps/app/app/(authenticated)/components/sidebar.tsx
Send a notification
Knock sends notifications using workflows. To send an in-app notification, create a new workflow in the Knock dashboard that uses thein-app
channel provider and create a corresponding message template.
Then you can trigger that workflow for a particular user in your app, passing in the necessary data to populate the message template:
notify.ts