Exposing Streams
Reference for exposing xs stores for remote access and connecting to remote stores.
Server: Exposing a Store
When running xs serve, you can expose your store for remote access using the --expose option with different networking protocols:
TCP (Traditional Networking)
Expose on a specific host and port:
xs serve ./store --expose :3021 # localhost on port 3021xs serve ./store --expose 192.168.1.100:8080 # specific hostIroh (Peer-to-Peer)
Expose via iroh for peer-to-peer QUIC connections:
xs serve ./store --expose iroh://When using iroh, the server will generate a connection ticket that clients can use to connect directly via QUIC, even across NATs and firewalls.
Getting the Connection Details
For TCP
The address you specify is the connection address:
- TCP:
:3021or192.168.1.100:8080
For Iroh
To get the iroh connection ticket, use the .last command:
.last xs.startThe ticket will be in the expose field of the metadata:
────────────┬───────────────────────────────────────────────── topic │ xs.start id │ 03ek4n3sq2i9fio5tc9wn9mov hash │ meta │ ─────────┬───────────────────────────────────── │ expose │ iroh://nodeaagxeomb7ezyg4prcpn... │ ─────────┴───────────────────────────────────── ttl │────────────┴─────────────────────────────────────────────────Client: Connecting to Remote Stores
All xs commands that accept an <addr> parameter can connect to remote stores:
TCP Connections
xs cat :3021"hello world" | xs append 192.168.1.100:8080 chatxs eval :3021 -c '.cat --topic notes'Iroh Connections
Use the full iroh ticket from the server:
xs cat iroh://nodeac4lrf7r5hyqeuj...crjpx6ajinb2hi4d"hello p2p QUIC" | xs append iroh://nodeac4lrf7r5hyqeuj...crjpx6ajinb2hi4d chatxs eval iroh://nodeac4lrf7r5hyqeuj...crjpx6ajinb2hi4d -c '.last status'Environment Configuration
XS_ADDR Environment Variable
Set $env.XS_ADDR to avoid repeating the connection address in xs.nu commands:
# TCP connection$env.XS_ADDR = ":3021"
# Iroh connection$env.XS_ADDR = "iroh://nodeac4lrf7r5hyqeuj...crjpx6ajinb2hi4d"With XS_ADDR set, xs.nu convenience functions will automatically use the remote store:
.cat # connects to $env.XS_ADDR"message" | .append logs # appends to remote store.last status # gets last from remote storeSee the xs.nu reference for all available convenience functions.
Connection Examples
Local Development
# Terminal 1: Start serverxs serve ./store --expose :3021
# Terminal 2: Connect and use$env.XS_ADDR = ":3021""development note" | .append notes.cat --followPeer-to-Peer QUIC Sharing
# Server: Start with irohxs serve ./store --expose iroh://
# Server: Get ticket.last xs.start
# Client: Connect with ticketxs cat iroh://nodeac4lrf7r5hyqeuj...crjpx6ajinb2hi4d --followRemote Evaluation
# Evaluate Nushell scripts on remote storexs eval :3021 -c '{topic: "heartbeat", timestamp: (date now)}'xs eval iroh://nodeac4lrf7r5hyqeuj...crjpx6ajinb2hi4d -c 'ls | each { $in } | .append files'