---
title: "CompressionOptions"
source: "https://github.com/remix-run/remix/blob/8905f3943706e1f53696ab83e70a84873cabfc90/packages/compression-middleware/src/lib/compression.ts#L11"
---

# CompressionOptions

## Summary

Configuration for automatic response compression.

## Signature

```ts
interface CompressionOptions {
  brotli?: BrotliOptions | ((response: Response) => BrotliOptions)
  encodings?: Encoding[] | ((response: Response) => Encoding[])
  filterMediaType?: (mediaType: string) => boolean
  threshold?: number
  zlib?: ZlibOptions | ((response: Response) => ZlibOptions)
}

```

## Properties

### `brotli`

node:zlib options for Brotli compression.
Can be static or a function that returns options based on the response.
HTML and SSE responses use `BROTLI_OPERATION_FLUSH` unless you explicitly set a flush value.

See: https://nodejs.org/api/zlib.html#class-brotlioptions

### `encodings`

Which encodings the server supports for negotiation in order of preference.
Can be static or a function that returns encodings based on the response.

Default: ['br', 'gzip', 'deflate']

### `filterMediaType`

Optional filter to control which responses get compressed based on media type.
If not provided, uses compressible media types from mime-db.

### `threshold`

Minimum size in bytes to compress (only enforced if Content-Length present).
Default: 1024

### `zlib`

node:zlib options for gzip/deflate compression.
Can be static or a function that returns options based on the response.
HTML and SSE responses use `Z_SYNC_FLUSH` unless you explicitly set a flush value.

See: https://nodejs.org/api/zlib.html#class-options