# Hono Integration

> Build a lightweight API with Hono and Sendable.

Source: https://wav1.recrav.com/docs/quickstart/nodejs/hono

## Project Setup [#project-setup]

```bash
mkdir my-sendable-api
cd my-sendable-api
npm init -y
npm install hono @hono/node-server
npm install -D typescript tsx
```

## Basic Server [#basic-server]

Create `src/index.ts`:

```typescript
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 [#run]

```bash
npx tsx src/index.ts
```

See full example on [GitHub](https://github.com/sendablelabs/examples/tree/main/hono).
