Guacamole JavaScript Client

1.5.0 · active · verified Sun Apr 19

guacamole-common-js is the core JavaScript client library for Apache Guacamole, an open-source, clientless remote desktop gateway. It encapsulates the necessary functionalities to establish and manage remote desktop connections (VNC, RDP, SSH, Telnet) directly within a web browser, communicating with a Guacamole server via an efficient HTTP tunnel. This specific package, currently at version 1.5.0, is a community-maintained fork of the official Guacamole client-side JavaScript, specifically prepared for distribution and consumption through npm. It combines and minifies all relevant JavaScript sources into a single bundle, simplifying integration into modern web projects. While it strives to align its version numbers with the upstream Apache Guacamole project, minor patch versions might append a letter (e.g., `1.0.0-b`) to denote fork-specific fixes or adjustments. The library's primary role is to provide the Guacamole protocol client and abstract drawing layers, enabling interactive remote desktop experiences purely in a browser without requiring dedicated client software.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to install the library, import the Guacamole client, set up an HTTP tunnel, and establish a basic connection to a Guacamole server to display a remote desktop within a specified HTML element.

import Guacamole from 'guacamole-common-js';

// Assumes a 'display' div exists in your HTML:
// <div id="display"></div>

// Create a Guacamole HTTP tunnel. Replace '/guacamole/tunnel' with your server's tunnel endpoint.
// This is the primary communication mechanism with the Guacamole server.
const tunnel = new Guacamole.HTTPTunnel("/guacamole/tunnel");

// Instantiate the Guacamole client, passing the tunnel
const client = new Guacamole.Client(tunnel);

// Get the display element from the client
const displayElement = client.getDisplay().getElement();

// Append the Guacamole display to your designated HTML element
document.getElementById("display").appendChild(displayElement);

// Handle client state changes (e.g., connection status)
client.onstatechange = function(state) {
    if (state === Guacamole.Client.State.DISCONNECTED) {
        console.log("Disconnected from Guacamole server.");
    } else if (state === Guacamole.Client.State.CONNECTED) {
        console.log("Connected to Guacamole server.");
    }
};

// Handle errors from the Guacamole client
client.onerror = function(error) {
    console.error("Guacamole client error:", error);
    alert("Connection error: " + error.message);
};

// Finally, connect to the Guacamole server
client.connect();

// To send user input (keyboard/mouse), you would typically use:
// const keyboard = new Guacamole.Keyboard(document);
// const mouse = new Guacamole.Mouse(displayElement);
// mouse.onmouseup = function(state) { client.sendMouseState(state); };
// keyboard.onkeydown = function(keysym) { client.sendKeyEvent(keysym, true); };

view raw JSON →