/webrtc-ip

🌐 Enhanced IP address querying with WebRTC

Primary LanguageTypeScriptApache License 2.0Apache-2.0


Build Status Apache 2.0 License Github contributors Snyk vulnerabilities PRs welcome


Installation

The webrtc-ip package is available through npm:

npm install webrtc-ip

Alternatively, install using bun:

bun install webrtc-ip

Usage

WebRTC-IP is intended to be used with Next.js. A minimal example is present in [website/example]:

import { useState, useEffect } from "react";
import { getIP } from 'webrtc-ip';

export default function Home() {
    const [ip, setIp] = useState<string>("0.0.0.0");

    useEffect(() => {
        (async () => {
            try {
                const ipAddress: string = await getIP();
                setIp(ipAddress);
            } catch (error) {
                console.error("Failed to fetch IP address:", error);
            }
        })();
    }, []);

    return (
        <main className="flex min-h-screen flex-col items-center justify-between p-24">
            <p>{ip}</p>
        </main>
    );
}

Authors

The author of webrtc-ips is Joey Malvinni

List of all contributors

License

Apache 2.0