Compress Middleware
This middleware compresses the response body, according to Accept-Encoding request header.
INFO
Note: On Cloudflare Workers, the response body will be compressed automatically, so there is no need to use this middleware.
Bun: This middleware uses CompressionStream which is not yet supported in bun.
Import
ts
import { Hono } from 'hono'
import { compress } from 'hono/compress'Usage
ts
const app = new Hono()
app.use(compress())Options
encoding:'gzip'|'deflate'- The compression scheme to allow for response compression. Either
gzipordeflate. If not defined, both are allowed and will be used based on theAccept-Encodingheader.gzipis prioritized if this option is not provided and the client provides both in theAccept-Encodingheader.
- The compression scheme to allow for response compression. Either
