Skip to Content
docshelpersAccepts

Last Updated: 3/9/2026


Accepts Helper

Accepts Helper helps to handle Accept headers in the Requests.

Import

import { Hono } from 'hono' import { accepts } from 'hono/accepts'

accepts()

The accepts() function looks at the Accept header, such as Accept-Encoding and Accept-Language, and returns the proper value.

import { accepts } from 'hono/accepts' app.get('/', (c) => { const accept = accepts(c, { header: 'Accept-Language', supports: ['en', 'ja', 'zh'], default: 'en', }) return c.json({ lang: accept }) })

AcceptHeader type

The definition of the AcceptHeader type is as follows.

export type AcceptHeader = | 'Accept' | 'Accept-Charset' | 'Accept-Encoding' | 'Accept-Language' | 'Accept-Patch' | 'Accept-Post' | 'Accept-Ranges'

Options

header: AcceptHeader

The target accept header.

supports: string[]

The header values which your application supports.

default: string

The default values.

match: (accepts: Accept[], config: acceptsConfig) => string

The custom match function.