A simple Deno-based Nostr client that connects to a relay and displays real-time text posts (kind 1 events). This application demonstrates basic Nostr protocol implementation using WebSocket connections.
- Real-time connection to Nostr relay
- Subscribes to text posts (kind 1 events) only
- Displays posts with timestamps and truncated author public keys
- Graceful shutdown with Ctrl+C
- Clean WebSocket connection management
- Deno installed on your system
- Basic understanding of the Nostr protocol
- Internet connection to access the relay
- Clone this repository:
git clone https://github.com/keix/nostr-client.git
cd nostr-reader
- Make sure you have Deno installed. If not, follow the official installation guide.
Run the application with Deno:
deno run --allow-net main.ts
The --allow-net
flag is required to allow WebSocket connections to the relay.
The application displays events in the following format:
-------------------
Time: [timestamp in local time]
Content: [post content]
Author: [first 8 characters of pubkey]...
Press Ctrl+C to gracefully shut down the application. This will:
- Unsubscribe from the relay
- Close the WebSocket connection
- Exit the program
The application uses the following default settings:
- Relay URL:
wss://relay.snort.social
- Event Types: Kind 1 (text notes) only
- Subscription: Only shows posts created after the application starts
To modify these settings, edit the following constants in the code:
RELAY_URL
: Change the relay serverkinds
array in thesubscribe()
method: Modify event types to subscribe toFilter
interface: Adjust subscription parameters
- WebSocket module:
deno.land/x/websocket@v0.1.4/mod.ts
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License, copyright (c) 2024 Kei Sawamura All rights reserved.