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:
Iroh (Peer-to-Peer)
Expose via iroh for peer-to-peer QUIC connections:
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:
The 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
|
Iroh Connections
Use the full iroh ticket from the server:
|
Environment Configuration
XS_ADDR Environment Variable
Set $env.XS_ADDR to avoid repeating the connection address in xs.nu commands:
# TCP connection
# Iroh connection
With XS_ADDR set, xs.nu convenience functions will automatically use the remote store:
|
See the xs.nu reference for all available convenience functions.
Connection Examples
Local Development
# Terminal 1: Start server
# Terminal 2: Connect and use
|
Peer-to-Peer QUIC Sharing
# Server: Start with iroh
# Server: Get ticket
# Client: Connect with ticket
Remote Evaluation
# Evaluate Nushell scripts on remote store