Back to Integrations
Edge Framework

Herald + Hono

Use Hono for a lightweight, ultra-fast notification API that works across all JavaScript runtimes (Node.js, Deno, Bun, Cloudflare Workers). Mount notification and webhook routes with minimal boilerplate — perfect for edge-deployed notification endpoints.

Ready to ship?

Start sending zero-PII notifications in minutes.

REGISTER YOUR WALLET
ZK-SECURE SOLANA NATIVE

Package: @herald-protocol/sdk

Install: npm install @herald-protocol/sdk hono

View full example on GitHub →

Server Setup

Minimal Hono app with route mounting.

Source →
Hono / Server Setup
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
import { Hono } from 'hono';
import { liquidationRoute } from './routes/liquidation';
import { webhookRoute } from './routes/webhooks';
import { usageRoute } from './routes/usage';
const app = new Hono();
app.route('/', liquidationRoute);
app.route('/', webhookRoute);
app.route('/', usageRoute);
const port = process.env.PORT ?? 3004;
export default {
port,
fetch: app.fetch,
};
console.log(`Hono Herald API running on http://localhost:${port}`);

Liquidation Route

POST /liquidation with validation and idempotency.

Source →
Hono / Liquidation Route
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { Hono } from 'hono';
import { Herald } from '@herald-protocol/sdk';
const herald = new Herald({ apiKey: process.env.HERALD_API_KEY! });
export const liquidationRoute = new Hono();
liquidationRoute.post('/liquidation', async (c) => {
const { wallet, positionId, healthFactor, debtAmount, asset } = await c.req.json();
if (!wallet || !positionId) {
return c.json({ error: 'wallet and positionId are required' }, 400);
}
const idempotencyKey = `liquidation_${positionId}_${Math.floor(Date.now() / 30000)}`;
const result = await herald.notify({
wallet,
subject: `⚠️ Liquidation Warning — Health factor: ${healthFactor}`,
body: [
`Position #${positionId} is approaching liquidation.`,
`Health factor: ${healthFactor}`,
`Debt: ${debtAmount} ${asset}`,
`Add collateral or repay immediately.`,
].join('\n'),
category: 'defi',
receipt: true,
idempotencyKey,
});
return c.json(result, 202);
});

Webhook Route

POST /webhooks/herald with HMAC verification.

Source →
Hono / Webhook Route
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { Hono } from 'hono';
import { Herald } from '@herald-protocol/sdk';
const WEBHOOK_SECRET = process.env.HERALD_WEBHOOK_SECRET!;
export const webhookRoute = new Hono();
webhookRoute.post('/webhooks/herald', async (c) => {
const signature = c.req.header('x-herald-signature');
const payload = await c.req.json();
const rawBody = JSON.stringify(payload);
if (!signature || !WEBHOOK_SECRET) {
return c.json({ error: 'Missing signature or secret' }, 401);
}
const isValid = await Herald.verifyWebhookSignature(rawBody, signature, WEBHOOK_SECRET);
if (!isValid) {
return c.json({ error: 'Invalid signature' }, 401);
}
switch (payload.event) {
case 'delivery.confirmed':
console.log(`${payload.notificationId} delivered`);
break;
case 'delivery.failed':
console.error(`${payload.notificationId} failed`);
break;
}
return c.json({ received: true });
});

Common Patterns

POST /liquidation — edge notification endpoint
POST /webhooks/herald — webhook verification at the edge
GET /usage — lightweight quota check
Runs on any JavaScript runtime

Start building with Herald

Clone the examples repo, copy the code that fits your stack, and deploy.