Skip to main content
Home

@std/net@1.0.4
Built and signed on GitHub Actions

Utilities for working with the network

This package works with DenoIt is unknown whether this package works with Bun
This package works with Deno
It is unknown whether this package works with Bun
JSR Score
94%
Published
10 months ago (1.0.4)
function getNetworkAddress
Unstable
getNetworkAddress(family?: Deno.NetworkInterfaceInfo["family"]): string | undefined

Gets the IPv4 or IPv6 network address of the machine.

Examples

Get the IPv4 network address (default)

import { getNetworkAddress } from "@std/net/unstable-get-network-address";

const hostname = getNetworkAddress()!;

Deno.serve({ port: 0, hostname }, () => new Response("Hello, world!"));

Get the IPv6 network address

import { getNetworkAddress } from "@std/net/unstable-get-network-address";

const hostname = getNetworkAddress("IPv6")!;

Deno.serve({ port: 0, hostname }, () => new Response("Hello, world!"));

Parameters

optional
family: Deno.NetworkInterfaceInfo["family"] = IPv4

The IP protocol version of the interface to get the address of.

Return Type

string | undefined

The IPv4 network address of the machine or undefined if not found.

See

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/net

Import symbol

import { getNetworkAddress } from "@std/net/unstable-get-network-address";
or

Import directly with a jsr specifier

import { getNetworkAddress } from "jsr:@std/net/unstable-get-network-address";

Add Package

bunx jsr add @std/net

Import symbol

import { getNetworkAddress } from "@std/net/unstable-get-network-address";