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

# Accepts Helper

> Content negotiation based on Accept headers

The Accepts Helper provides content negotiation functionality based on HTTP Accept headers.

## Import

```typescript theme={null}
import { accepts } from 'hono/accepts'
```

## Functions

### accepts()

Determine the best match for the given Accept header.

```typescript theme={null}
function accepts(c: Context, type: string | string[]): string | null
```

<ParamField path="c" type="Context" required>
  The context object
</ParamField>

<ParamField path="type" type="string | string[]" required>
  The content type(s) to match against
</ParamField>

<ResponseField name="return" type="string | null">
  The best matching content type or null if no match
</ResponseField>

**Example**

```typescript theme={null}
import { accepts } from 'hono/accepts'

app.get('/data', (c) => {
  const accept = accepts(c, ['application/json', 'text/html'])
  
  if (accept === 'application/json') {
    return c.json({ data: 'value' })
  } else if (accept === 'text/html') {
    return c.html('<html>...</html>')
  }
  
  return c.text('Not Acceptable', 406)
})
```

## Advanced Usage

```typescript theme={null}
import { accepts } from 'hono/accepts'

// Language negotiation
app.get('/', (c) => {
  const lang = accepts(c, ['en', 'ja', 'fr'])
  return c.text(`Language: ${lang}`)
})

// Compression negotiation
app.get('/file', (c) => {
  const encoding = accepts(c, ['gzip', 'deflate', 'br'])
  // Use the preferred encoding
})
```
