Skip to content

Connecting to a Relay

You must connect your nostr Client to a relay in order to send and receive Events. Instantiate a Nostr::Client and a Nostr::Relay giving it the url of your relay. The name attribute is just descriptive. Calling Client#connect attempts to establish a WebSocket connection between the Client and the Relay.

client =
relay = 'wss://', name: 'Damus')

# Listen for the connect event
client.on :connect do
  # When this block executes, you're connected to the relay

# Connect to a relay asynchronously