• Get the current public IP Address

    (i) This uses fetch + https://ip.rjns.dev (located in germany, falkenstein - no logs)

    Type Parameters

    • Type extends undefined | "v4" | "v6"

    Parameters

    Returns Promise<(Type extends "v4"
        ? Type extends "v6"
            ? IPAddress<4> | IPAddress<4>
            : IPAddress<4>
        : IPAddress<6>) | null>

    Example

    import { network } from "@rjweb/utils"

    console.log(`View at http://${(await network.currentIP('v4'))?.long()} or http://[${(await network.currentIP('v6'))?.long()}]`)

    Since

    1.8.4

    Supports

    nodejs, browser