QuickstartNodejs
Hono Integration
Build a lightweight API with Hono and Sendable.
Project Setup
mkdir my-sendable-api
cd my-sendable-api
npm init -y
npm install hono @hono/node-server
npm install -D typescript tsxBasic Server
Create src/index.ts:
import { Hono } from 'hono'
import { serve } from '@hono/node-server'
const app = new Hono()
app.post('/send', async (c) => {
const { to, text } = await c.req.json()
const response = await fetch('https://api.sendable.dev/messages/send', {
method: 'POST',
headers: {
'x-api-key': process.env.SENDABLE_API_KEY!,
'Content-Type': 'application/json',
},
body: JSON.stringify({ to, text }),
})
return c.json(await response.json())
})
app.post('/webhook', async (c) => {
const body = await c.req.json()
console.log('Webhook:', body)
return c.json({ received: true })
})
serve({ fetch: app.fetch, port: 3000 })Run
npx tsx src/index.tsSee full example on GitHub.