# @types/on-headers

> TypeScript definitions for on-headers

Latest version **1.0.4** (published 2025-06-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/on-headers
pnpm add @types/on-headers
yarn add @types/on-headers
bun add @types/on-headers
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; popular repo; extremely popular.

Warnings: low downloads; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2025-06-07 |
| First published | 2016-05-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51420 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/on-headers
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/on-headers
- npm.io page: https://npm.io/package/@types/on-headers

## Dependencies (1)

- [@types/node](https://npm.io/package/@types/node.md) *

## Recent versions

- 1.0.4 (latest) — 2025-06-07
- 1.0.3 (ts4.9) — 2023-11-07
- 1.0.1 (ts4.3) — 2023-09-03
- 1.0.0 (ts3.9) — 2017-08-22
- 1.0.2 — 2023-10-18
- 2.1.30 — 2017-08-21
- 2.1.29 — 2016-09-19
- 2.1.28 — 2016-07-14
- 2.1.27-alpha — 2016-07-08
- 2.1.26-alpha — 2016-07-04
- 2.1.25-alpha — 2016-07-02
- 2.1.24-alpha — 2016-07-01
- 2.1.23-alpha — 2016-07-01
- 2.1.22-alpha — 2016-05-25
- 2.1.21-alpha — 2016-05-20
- … 2 more at https://npm.io/package/@types/on-headers/versions

## README

# Installation
> `npm install --save @types/on-headers`

# Summary
This package contains type definitions for on-headers (https://github.com/jshttp/on-headers).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/on-headers.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/on-headers/index.d.ts)
````ts
/// <reference types="node" />

import { ServerResponse } from "http";

/**
 * This will add the listener to fire when headers are emitted for res.
 * The listener is passed the response object as its context (this).
 * Headers are considered emitted only once, right before they
 * are sent to the client.
 *
 * When this is called multiple times on the same res, the listeners
 * are fired in the reverse order they were added.
 *
 * @param res HTTP server response object
 * @param listener Function to call prior to headers being emitted,
 *        the response object is passed as this context.
 */
declare function onHeaders(res: ServerResponse, listener: (this: ServerResponse) => void): void;

export = onHeaders;

````

### Additional Details
 * Last updated: Sat, 07 Jun 2025 02:15:25 GMT
 * Dependencies: [@types/node](https://npmjs.com/package/@types/node)

# Credits
These definitions were written by [John Jeffery](https://github.com/jjeffery), [BendingBender](https://github.com/BendingBender), and [Sebastian Beltran](https://github.com/bjohansebas).

---
_Source: https://npm.io/package/@types/on-headers · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
