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();
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:8765/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",
port: 8765,
store: false,
path: "public",
showQr: "false",
});
Alternatively, create a .env
file and add the following defaults:
RELAY_HOST="localhost"
RELAY_STORE=false
RELAY_PORT=8765
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.