1.0.0 • Published 7 months ago

react-vnc v1.0.0

Weekly downloads
-
License
-
Repository
github
Last release
7 months ago

Issues

Table of Contents

About The Project

noVNC is a VNC client web application using which you can view a VNC stream directly on a browser. It uses websockify to convert the VNC stream into a websocket stream, which can be viewed on a browser. This library provides a React component wrapper around the noVNC web client.

Using this library, you can easily display a VNC stream on a page of your web application. Here is an example.

Demo

A demo website using the react-vnc library is hosted on https://roerohan.github.io/react-vnc/. The source for this application can be found in src/App.tsx.

Built With

Getting Started

Installation

To install the library, you can run the following command:

npm i react-vnc

Contribution

In order to run the project locally, follow these steps:

  1. Clone the repository.
git clone git@github.com:roerohan/react-vnc.git
cd react-vnc
  1. Install the packages and submodules.
npm install
git submodule update --init --recursive
  1. To run the sample react-vnc web application:
echo "REACT_APP_VNC_URL=ws://your-vnc-url.com" > .env
npm start
  1. To build the library, make changes inside the lib folder, then run:
npm run build:lib

Usage

A VncScreen component is exposed from the library, to which you can pass the required and optional props. For example,

import React, { useRef } from 'react';
import { VncScreen } from 'react-vnc';

function App() {
  const ref = useRef();

  return (
    <VncScreen
      url='ws://your-vnc-url.com'
      scaleViewport
      background="#000000"
      style={{
        width: '75vw',
        height: '75vh',
      }}
      ref={ref}
    />
  );
}

export default App;

The only required parameter is url, which must be a ws:// or a wss:// (websocket) URL for the library to function properly. noVNC can display only websocket URLs. All other props to VncScreen are optional. The following is a list (an interface) of all props along with their types.

interface Props {
  url: string;
  style?: object;
  className?: string;
  viewOnly?: boolean;
  rfbOptions?: Partial<RFBOptions>;
  focusOnClick?: boolean;
  clipViewport?: boolean;
  dragViewport?: boolean;
  scaleViewport?: boolean;
  resizeSession?: boolean;
  showDotCursor?: boolean;
  background?: string;
  qualityLevel?: number;
  compressionLevel?: number;
  autoConnect?: number; // defaults to true
  retryDuration?: number; // in milliseconds
  debug?: boolean; // show logs in the console
  loadingUI?: React.ReactNode; // custom component that is displayed when loading
  onConnect?: (rfb?: RFB) => void;
  onDisconnect?: (rfb?: RFB) => void;
  onCredentialsRequired?: (rfb?: RFB) => void;
  onSecurityFailure?: (e?: { detail: { status: number, reason: string } }) => void;
  onClipboard?: (e?: { detail: { text: string } }) => void;
  onBell?: () => void;
  onDesktopName?: (e?: { detail: { name: string } }) => void;
  onCapabilities?: (e?: { detail: { capabilities: RFB["capabilities"] } }) => void;
}

// The rfbOptions object in Props is of type Partial<RFBOptions>
interface RFBOptions {
    shared: boolean;
    credentials: {
        username?: string;
        password?: string;
        target?: string;
    };
    repeaterID: string;
    wsProtocols: string | string[];
}

To know more about these props, check out API.md.

You can pass a ref to the VncScreen component, and access the connect() and disconnect() methods from the library. Check out #18 for more details.

The onConnect, onDisconnect, onCredentialsRequired, and onDesktopName props are optional, and there are existing defaults set for them. For example, the default onDisconnect function consists of some logic to retry connecting after a certain timeout (specified by retryDuration). Check out the default _onConnect and _onDisconnect functions in VncScreen.tsx for more details.

The onConnect, onDisconnect, and onCredentialsRequired callbacks can accept a single parameter rfb. This parameter is the RFB object, which is described by noVNC. Learn more about the RFB object here.

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'feat: Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

You are requested to follow the contribution guidelines specified in CONTRIBUTING.md while contributing to the project :smile:.

License

Distributed under the MIT License. See LICENSE for more information.

1.0.0

7 months ago

0.5.16

7 months ago

0.5.15

8 months ago

0.5.10

12 months ago

0.5.11

11 months ago

0.5.14

9 months ago

0.5.12

10 months ago

0.5.13

9 months ago

0.5.8

1 year ago

0.5.9

1 year ago

0.5.7

1 year ago

0.5.6

1 year ago

0.5.5

1 year ago

0.5.4

2 years ago

0.5.3

2 years ago

0.5.2

2 years ago

0.5.1

2 years ago

0.4.4

2 years ago

0.5.0

2 years ago

0.4.1

2 years ago

0.4.3

2 years ago

0.4.2

2 years ago

0.2.10

2 years ago

0.3.0

2 years ago

0.2.9

2 years ago

0.2.8

2 years ago

0.4.0

2 years ago

0.2.7

2 years ago

0.2.6

3 years ago

0.2.5

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.4

3 years ago

0.1.18

3 years ago

0.1.11

3 years ago

0.1.12

3 years ago

0.1.13

3 years ago

0.1.14

3 years ago

0.1.15

3 years ago

0.1.16

3 years ago

0.1.17

3 years ago

0.1.10

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago