Share your localhost with the Colyseus Tunnel

Share your localhost with the Colyseus Tunnel

Put the multiplayer game running on your machine on a public URL. Press s in vite dev, or run npx colyseus-tunnel, and send your peers a link or a QR code.


Multiplayer games are hard to test alone. Until now, getting a second player into the build on your machine meant deploying it somewhere, or setting up a third-party tunnel and pointing your client at it.

The Colyseus Tunnel puts the game running on your machine on a public URL, such as https://mygame.play.colyseus.dev. Your peers open the link, or scan a QR code with their phone, and play against your local server.

Terminal window
npm install --save-dev @colyseus/tunnel

The tunnel is in preview and free to use. You need a Colyseus Cloud account, and any member of a team can share through it.

Why a tunnel made for game servers

  • The whole game goes through one URL. The page, its WebSockets and WebTransport all reach your machine over HTTPS, so the client connects to the same origin it was loaded from.
  • It works behind NAT and firewalls. Nothing on your machine listens on the internet. There is no port forwarding to configure on a home router or an office network.
  • It works on real devices. The terminal prints a QR code, so you can open your local build on a phone without being on the same Wi-Fi.
  • Hot reload reaches everyone. With the Vite plugin, your code changes reach your playtesters the same way they reach your own browser.

Share from Vite

If you use the Colyseus Vite plugin, sharing is one keypress. You need colyseus@0.18.12 or later.

Start your dev server:

Terminal window
npx vite

Then press s followed by Enter. The first time, your browser opens Colyseus Cloud. Log in, check the team, and select Share.

The terminal then shows the public URL, with a QR code below it:

➜ Shared: https://k3x9w2ab.play.colyseus.dev/

Press s again to show them again. The URL stays the same until you stop Vite.

Pick a name for your URL

By default the name is random. To ask for a specific one, set the plugin’s tunnel option:

vite.config.ts
import { defineConfig } from 'vite';
import { colyseus } from 'colyseus/vite';
export default defineConfig({
plugins: [
colyseus({
serverEntry: '/src/server/index.ts',
tunnel: { name: 'mygame' }, // https://mygame.play.colyseus.dev
}),
],
});

Names are first come, first served. Set tunnel: false to remove the s shortcut.

Share from the command line

You don’t need Vite to use the tunnel. colyseus-tunnel shares any local server by its port:

Terminal window
npx colyseus-tunnel 2567 # a random name
npx colyseus-tunnel -n mygame 2567 # https://mygame.play.colyseus.dev

The port can also be host:port, such as [::1]:5173. Press Ctrl+C to stop sharing, and run npx colyseus-tunnel logout to forget your login on this machine.

This works for any setup: a Colyseus server started with npm start, a Unity or Godot client talking to a local server, or a dev server from another bundler.

Share from code

The same tunnel is available as an API, for custom dev scripts and tooling:

import { openTunnel, qrCode } from '@colyseus/tunnel';
const tunnel = await openTunnel({ local: 2567 });
console.log(tunnel.url);
console.log(qrCode(tunnel.url));
// later
await tunnel.close();

What your playtesters can reach

A public URL to a dev server deserves some care, because a dev server can serve any file in your project.

With the Vite plugin, playtesters get what vite build would ship: the files in public/, your pages, and what they load, from imports to the assets beside them. Every other file in your project answers 404, such as a data/ folder, scripts or keys. Files in your server entry’s folder answer 404 too, so keep server-only code there. Your client can still use import type from that folder, because a type import leaves no request behind.

If your page fetches a file at runtime, put it in public/, as you would for a build. Vite’s terminal names each file the tunnel kept out.

Without the Vite plugin, whatever your local server answers is public, including the playground and the monitor if your server mounts them.

Every tunnel refuses secret files such as .env, .git/ and keys.

Remote shells, CI and containers

The login needs a browser once per machine. In a remote shell, BROWSER=none prints the login link instead of opening it.

For CI or a container, set COLYSEUS_CLOUD_TOKEN to a tunnel token. After one login, your token is in ~/.colyseus/tunnel.json.

Current limits

  • The tunnel runs on macOS and Linux (x64 and arm64), and on Windows (x64).
  • The Vite dev server must use plain HTTP: server.https isn’t supported yet.
  • Every request travels through the tunnel’s server in San Francisco, so playtesters far from it see extra latency. Use the tunnel for playtests, not for latency measurements.

Try it

The tunnel is available now as @colyseus/tunnel. The full guide is on the docs: Share your dev server.

No game to share yet? One prompt gets your coding agent from an empty folder to a Vite multiplayer game you can share this way.

It’s a preview, so we want to hear how it holds up in your playtests. Join us on Discord or open an issue on GitHub.

Colyseus Cloud

Deploy Your Servers in Minutes

Colyseus Cloud is ready to serve hundreds and thousands of CCU. No ops required.

Learn more about Colyseus Cloud