npm add @nostr-dev-kit/ndk
NDK uses the debug
package to assist in understanding what’s happening behind the hood. If you are building a package
that runs on the server define the DEBUG
envionment variable like
export DEBUG='ndk:*'
or in the browser enable it by writing in the DevTools console
localStorage.debug = 'ndk:*'
You can construct NDK passing a netDebug callback to receive network traffic events, particularly useful for debugging applications not running in a browser.
const netDebug = (msg: string, relay: NDKRelay, direction?: "send" | "recv") = {
const hostname = new URL(relay.url).hostname;
netDebug(hostname, msg, direction);
}
ndk = new NDK({ netDebug });