Demo
If you want to try the Mini App notification experience, you can try the Monad Mini App Template app.Modifying the Mini App manifest
Mini App account association process has to be completed before the Mini App can send notifications.
- The user has added the Mini App and not disabled notifications manually
- The user has explicitly subscribed to notifications from the Mini App
miniapp_added, miniapp_removed, notifications_disabled and notifications_enabled to the Mini App’s webhook endpoint, this allows the Mini App to keep track of which users the Mini App can send notifications to.
The webhookUrl has to be specified in the Mini App manifest file:
app/.well-known/farcaster.json/route.ts
webhookUrl.
Processing Farcaster client events
The code for processing webhook events can be found in the file/app/api/webhook/route.ts.
Verifying webhook events
Events are signed by the app key of a user with a JSON Farcaster Signature. This allows Mini Apps to verify the Farcaster client that generated the notification and the Farcaster user they generated it for. It is important to verify events in order to make sure the Mini App is correctly tracking which users it can send notifications to. If you are using the Monad Mini App template, the code for verifying events is already available in/app/api/webhook/route.ts. If not, you can copy code from the same file.
A Neynar API key is required to verify webhook events. You can sign up to the Neynar service and get an API key for free.Once done, add a environment variable named
NEYNAR_API_KEY to your .env file.Processing webhook payload
Once thewebhookUrl is specified, Farcaster app and clients will send client events to the webhook endpoint.
The miniapp_added and notifications_enabled events are received by the Mini App along with fid and notificationDetails.
notificationDetails has a url and a token that can be used to send notifications to a specific Farcaster user.
Example of webhook payload:
/app/api/webhook/route.ts.
The Mini App can use any database service of choice to store the url and token and use it when sending notifications.
The Monad Mini App template uses Upstash’s Redis service for storing the notificationDetails, if you wish to use a different database you can modify it in /lib/kv.ts.
Since the Monad Mini App template uses Redis for storing notification url and token, environment variables
UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN are required in .env.Once you sign up for the Upstash service and create a Redis database you will be able to get these environment variables.If you plan to use some other database, adjust environment variables accordingly./lib/kv.ts
Sending notifications

POST request to the url associated with that token.
If you are using the Monad Mini App template the code for sending notification is already available in the file /app/api/send-notification/route.ts. If not, you can copy code from /lib/notifs.ts and /app/api/send-notification/route.ts.
Personalizing notification content
You can change a few lines of code in/app/api/send-notification/route.ts file to personalize the notification:
/app/api/send-notification/route.ts
POST to /api/send-notification endpoint!
That’s all you need to send notifications to your Mini App users!
