@gun-vue/relay
v0.6.0
Published
A simple GUN peer relay for self- hosting
Downloads
110
Readme
Gun-Vue: Relay
GitHub (/relay) • npm • Docs A simple Gun relay peer in Node.js.
This package is part of Gun-Vue: The Peer-to-Peer Web App Toolkit
How to Install
Requirements
Instructions
- Create a new Node.js project:
npm init -y
- Install the Gun-Vue: Relay package as a dependency:
npm i @gun-vue/relay
- Open
package.json
and add:
"scripts": {
"start": "node start.js"
}
- Create a
start.js
script and add:
import relay from "@gun-vue/relay";
relay.init();
- Test the relay:
node start.js
Hello wonderful person! :) Thanks for using GUN, please ask for help on http://chat.gun.eco if anything takes you longer than 5min to figure out!
AXE relay enabled!
Server started at http://localhost:4200/gun
Multicast on 233.255.255.255:8765
Options
The relay can be customized with an options object by updating start.js
:
relay.init({
host: "localhost", // Domain or IP address where your relay is hosted (no 'http://')
port: 4200, // The port your relay will listen on (e.g., 8080)
store: false, // Use 'true' to enable persistent storage on disk
path: "public", // Folder to serve static files (e.g., your front-end build)
showQr: "false", // Render a QR Code Link to the server
});
Alternatively, create a .env
file and add the following defaults:
RELAY_HOST="localhost"
RELAY_STORE=false
RELAY_PORT=4200
RELAY_PATH="public"
RELAY_QR=false
Standalone Executable
You can build a standalone executable that bundles Node.js runtime with the relay server. This creates a larger file (≈90MB) but allows for easy distribution and running without Node.js installation.
Building the Executable
- Clone the repository and install dependencies:
pnpm install
- Browse the /relay/ folder and build the bundled application:
cd relay
pnpm build
- Create the platform-specific executable:
For MacOS:
pnpm app:macos
For Windows:
pnpm app:windows
For Linux:
pnpm app:linux
The executable will be created in the dist
folder as:
- MacOS:
gun-relay
- Windows:
gun-relay.exe
- Linux:
gun-relay-linux
Running the Executable
Simply double-click the executable or run it from the terminal:
./dist/gun-relay # MacOS/Linux
.\dist\gun-relay.exe # Windows
The relay will start with default settings. You can still use environment variables to configure it by creating a .env
file in the same directory as the executable.