Fonstr is a simple and efficient Nostr relay server designed to run on mobile phones. It can be run in one line of code. For more information about fonstr, see this blog post.
To run the Fonstr Nostr relay with just one line of code, use:
npx fonstr [port]
Replace [port]
with the desired port number. If no port is provided, the server will run on port 4444 by default.
If you have installed the package globally or linked it, you can run:
fonstr [port]
Alternatively, you can run the server using node
:
node index.js [port]
Now the Nostr relay server will be up and running, ready to handle incoming events and subscriptions.
To run with HTTPS, use -h
or --https
and use ./fullchain.pem
and ./privkey.pem
.
First, clone the repository and navigate to the project directory:
git clone https://github.com/nostrapps/fonstr.git
cd fonstr
Then, install the necessary dependencies:
npm install
First, navigate to the root directory of the project, where the Dockerfile is located, and run the following command:
docker build -t fonstr .
Run a container using the built image. Map the port and mount a volume to persist the data directory.
docker run -d -p 4444:4444 fonstr
This Nostr relay server supports the following Nostr event types:
EVENT
: Publish an eventREQ
: Subscribe to events with specified filtersCLOSE
: Unsubscribe from a subscriptionEOSE
: End of subscription events signal// Connect to the Nostr relay server using a WebSocket
const socket = new WebSocket('ws://localhost:4444');
// Subscribe to events
socket.send(JSON.stringify(['REQ', 'subscription_id', { types: [1, 2, 3], kind: 1 }]));
// Listen for incoming events
socket.addEventListener('message', (event) => {
const data = JSON.parse(event.data);
console.log('Received data:', data);
});
This project is licensed under the MIT License. See LICENSE for more information.
Contributions are welcome! Feel free to open a pull request or report any issues you find.