Ever wondered how tools like AnyDesk or TeamViewer let you control a remote computer right from your browser? In this guide, we’ll build exactly that — a browser-based remote desktop app using noVNC, websockify, and Node.js.
By the end, you’ll have a working screen sharing app where anyone can connect to a remote machine from a web browser — no client software needed.
What We’re Building
A remote desktop system with:
A VNC server on the host machine (the one being shared)
A WebSocket bridge to relay VNC traffic over the web
A noVNC HTML5 client that runs entirely in the browser
A Node.js + Express backend to manage sessions and serve the app
This is the same architecture used by cloud providers like AWS, DigitalOcean, and Gitpod for their browser-based terminals and desktops.
How It Works
[Browser] ←→ WebSocket ←→ [websockify] ←→ TCP ←→ [VNC Server] ←→ [Desktop]
A VNC server (like x11vnc or TigerVNC) captures the screen and handles input on the host machine
websockify acts as a bridge — it converts WebSocket connections from the browser into plain TCP connections that the VNC server understands
noVNC is a JavaScript VNC client that runs in the browser and talks to websockify over WebSockets
Prerequisites
A Linux machine (Ubuntu 20.04+ recommended) as the host
Node.js 18+
Python 3 (for websockify)
A desktop environment (GNOME, XFCE, etc.) or a virtual display
sudo apt update
sudo apt install -y x11vnc xvfb websockify nodejs npm
Step 1: Set Up a Virtual Display (Optional)
If your server doesn’t have a physical monitor, create a virtual display using Xvfb:
Start a virtual display on screen :1
Xvfb :1 -screen 0 1920x1080x24 &
Set the display environment variable
export DISPLAY=:1
To verify it’s running:
DISPLAY=:1 xterm & # Should open a terminal on the virtual display
Step 2: Start the VNC Server
We’ll use x11vnc to capture the display and expose it over VNC:
x11vnc -display :1 \
-rfbport 5901 \
-passwd yourpassword \
-forever \
-shared \
-noxdamage
view full post visit my medium
https://medium.com/@deepakmukundpur/build-a-screen-sharing-app-using-novnc-like-anydesk-03a31def47cc
Top comments (0)