---
title: "Deploy xnet-hub"
description: "Deploy an xnet.fyi hub server for always online sync and backup"
category: "Other"
url: https://railway.com/deploy/xnet-hub
---

# Deploy xnet-hub

Deploy an xnet.fyi hub server for always online sync and backup

**[Deploy xnet-hub on Railway](https://railway.com/template/xnet-hub)**

- **Creator:** Chris S.'s Projects
- **Category:** Other

## Template content

### xNet

- **Source:** crs48/xNet

## Documentation

# Deploy and Host xnet-hub on Railway

xnet-hub is the sync server for xNet, a local-first, CRDT-backed workspace. One Node.js binary provides WebSocket sync relay, WebRTC signaling, encrypted backup, file storage, full-text search, and federation for xNet clients. Your devices work offline and merge changes conflict-free; the hub keeps them in sync and backed up.

## About Hosting xnet-hub

xnet-hub runs as a single Node.js server with SQLite storage — no external database required. The Docker image builds from the xNet monorepo, compiles native SQLite bindings, and starts the hub via its CLI. Attach a Railway volume at `/data` for persistent storage, and Railway's `$PORT` is passed straight to the server. A `/health` endpoint (which also serves the hub's DID) powers Railway health checks, with automatic restarts on failure. Roles are config presets on the same binary: run it as a personal hub, a team relay, or a demo hub with quotas and periodic eviction. Optional Litestream support streams SQLite replicas to S3-compatible storage.

## Common Use Cases

- Personal always-on sync and backup node, so your xNet workspaces stay in sync across desktop, web, and mobile even when your other devices are offline
- Team or community hub relaying real-time collaborative edits (Yjs CRDTs), presence, and file attachments between members
- Self-hosted alternative to the managed xNet cloud — own your data end to end, including full-text search over your own backups

## Dependencies for xnet-hub Hosting

- A Railway volume mounted at `/data` (SQLite database and file blobs live there; without it, data is lost on redeploy)
- Nothing else — SQLite is embedded, so no separate database service is needed

### Deployment Dependencies

- [xNet on GitHub](https://github.com/crs48/xNet) — source for the hub and the monorepo Dockerfile
- [xNet](https://xnet.fyi) — the app that connects to this hub
- [Litestream](https://litestream.io) — optional continuous SQLite replication to S3-compatible storage

### Implementation Details

The container reads Railway's `$PORT` and stores everything under the mounted volume:

```bash
node packages/hub/dist/cli.js --port $PORT --data /data
```

Useful environment variables:

- `HUB_PUBLIC_URL` — the public `wss://` URL of your deployment; required for share links to mint correctly
- `HUB_ROLE` — role preset (`personal`, `demo`, …); a role is pure config, never a code branch
- `LITESTREAM=1` plus S3 credentials — enable streaming SQLite backups

Health checks hit `GET /health`, which returns status and the hub's DID.

## Why Deploy xnet-hub on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying xnet-hub on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.

## Similar templates

- [Rocky Linux](https://railway.com/deploy/rocky-linux) — [Jul'26] Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀
- [Foundry Virtual Tabletop](https://railway.com/deploy/X5tR6G) — A Self-Hosted & Modern Roleplaying Platform
- [Letta Code Remote](https://railway.com/deploy/letta-code-remote) — Run a Letta Code agent 24/7. No inbound ports, just deploy.

Open this page in a browser: https://railway.com/deploy/xnet-hub
