Skip to main content
ServerResponse.prototype.writeEarlyHints - node__http.d.ts - Node documentation
method ServerResponse.prototype.writeEarlyHints

Usage in Deno

```typescript import { ServerResponse } from "node:node__http.d.ts"; ```
ServerResponse.prototype.writeEarlyHints(
hints: Record<string, string | string[]>,
callback?: () => void,
): void
Sends an HTTP/1.1 103 Early Hints message to the client with a Link header, indicating that the user agent can preload/preconnect the linked resources. The `hints` is an object containing the values of headers to be sent with early hints message. The optional `callback` argument will be called when the response message has been written. **Example** ```js const earlyHintsLink = '; rel=preload; as=style'; response.writeEarlyHints({ 'link': earlyHintsLink, }); const earlyHintsLinks = [ '; rel=preload; as=style', '; rel=preload; as=script', ]; response.writeEarlyHints({ 'link': earlyHintsLinks, 'x-trace-id': 'id for diagnostics', }); const earlyHintsCallback = () => console.log('early hints message sent'); response.writeEarlyHints({ 'link': earlyHintsLinks, }, earlyHintsCallback); ```

Parameters

hints: Record<string, string | string[]>
An object containing the values of headers
optional
callback: () => void
Will be called when the response message has been written

Return Type

void