Skip to main content
URL.prototype.host - node__url.d.ts - Node documentation
property URL.prototype.host

Usage in Deno

```typescript import { URL } from "node:node__url.d.ts"; ```
Gets and sets the host portion of the URL. ```js const myURL = new URL('https://example.org:81/foo'); console.log(myURL.host); // Prints example.org:81 myURL.host = 'example.com:82'; console.log(myURL.href); // Prints https://example.com:82/foo ``` Invalid host values assigned to the `host` property are ignored.

Type

string