> ## Documentation Index
> Fetch the complete documentation index at: https://armory.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# With Hono

> Accept Armory payments in Hono

Accept crypto payments in your Hono API with the Armory middleware.

## Installation

```bash theme={null}
# npm
npm install @armory-sh/middleware-hono

# yarn
yarn add @armory-sh/middleware-hono

# pnpm
pnpm add @armory-sh/middleware-hono

# bun
bun add @armory-sh/middleware-hono
```

## Quick Start

```typescript theme={null}
import { Hono } from 'hono';
import { acceptPaymentsViaArmory } from '@armory-sh/middleware-hono';

const app = new Hono();

// Protect all routes
app.use('*', acceptPaymentsViaArmory({
  payTo: '0xYourWalletAddress...',
  amount: '1.0'
}));

app.get('/api/data', (c) => {
  return c.json({ message: 'Payment successful!' });
});

app.listen(3000);
```

***

## Accessing Payment Info

Payment information is stored in the Hono context:

```typescript theme={null}
app.get('/api/user', (c) => {
  const payment = c.get('payment');
  const { payerAddress, payload } = payment;

  return c.json({
    message: `Hello ${payerAddress}`,
    paid: payload.amount
  });
});
```

***

## Protecting Specific Routes

Use path patterns to protect specific route groups:

```typescript theme={null}
// Public routes — no payment
app.get('/', (c) => c.json({ message: 'Welcome' }));

// All /api/* routes require payment
app.use('/api/*', acceptPaymentsViaArmory({
  payTo: '0x...',
  amount: '1.0'
}));

app.get('/api/data', (c) => c.json({ data: '...' }));
```

***

## Multi-Network Support

Accept payments across multiple networks:

```typescript theme={null}
app.use('/api/*', acceptPaymentsViaArmory({
  payTo: '0x...',
  amount: '1.0',
  accept: {
    networks: ['base', 'ethereum', 'polygon'],
    tokens: ['usdc', 'usdt']
  }
}));
```

## Route Configuration

For route-specific configuration, use `routeAwarePaymentMiddleware`:

```typescript theme={null}
import { routeAwarePaymentMiddleware } from '@armory-sh/middleware-hono';

app.use('/api/*', routeAwarePaymentMiddleware({
  routes: ['/api/basic', '/api/premium/*'],
  payTo: '0xYourAddress...',
  amount: '$1.00',
  network: 'base',
  perRoute: {
    '/api/premium/*': {
      amount: '$5.00'
    }
  }
}));
```

***

## Tips

<Tip>
  The `amount` parameter accepts human-readable strings like `"1.0"` for 1 token — no need to calculate decimals manually.
</Tip>

<Note>
  Hono's middleware matching is pattern-based. Use `/api/*` to protect all API routes, or `/premium/*` for paid content only.
</Note>

***

## More Information

See [`@armory-sh/middleware-hono`](/packages/middleware-hono) for full configuration options.
