@simplehook/hono
v0.3.2
Published
Stable webhook URLs for localhost. One line of code. Hono adapter.
Maintainers
Readme
@simplehook/hono
One line of code to receive webhooks locally in Hono. No tunnels, no CLI, no ngrok.
listenToWebhooks(app, process.env.SIMPLEHOOK_KEY);Your app opens an outbound WebSocket to simplehook.dev. When a webhook arrives at your stable URL, it's forwarded to your local Hono server. Your response goes back to the caller. Set your webhook URL once in Stripe/GitHub/Twilio and never change it.
Install
npm install @simplehook/honoQuick Start
import { Hono } from "hono";
import { listenToWebhooks } from "@simplehook/hono";
const app = new Hono();
listenToWebhooks(app, process.env.SIMPLEHOOK_KEY);
app.post("/stripe/events", async (c) => {
const body = await c.req.json();
console.log("Webhook received!", body);
return c.json({ received: true });
});
export default app;API
listenToWebhooks(app, apiKey, options?): Connection
Connects your Hono app to simplehook and returns a Connection handle.
const conn = listenToWebhooks(app, apiKey, {
forceEnable: false, // Connect even in production
serverUrl: "...", // Override server URL
onConnect: () => {}, // Called when connected
onDisconnect: () => {}, // Called when disconnected
silent: false, // Suppress console output
});
// Later: conn.close();listenToWebhooks(app, apiKey, listenerId, options?)
Pass a listener ID to route events to a specific SDK instance. Create listeners in the dashboard.
listenToWebhooks(app, process.env.SIMPLEHOOK_KEY, "staging");Dev Mode
By default, simplehook only connects in development (NODE_ENV !== "production"). Use forceEnable: true to override, or set SIMPLEHOOK_ENABLED=false to disable explicitly.
Links
License
MIT
