
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
A React Component to connect to a websockified VNC client using noVNC.
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
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.
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.
To install the library, you can run the following command:
npm i react-vnc
In order to run the project locally, follow these steps:
git clone git@github.com:roerohan/react-vnc.git
cd react-vnc
npm install
git submodule update --init --recursive
react-vnc
web application:echo "REACT_APP_VNC_URL=ws://your-vnc-url.com" > .env
npm start
lib
folder, then run:npm run build:lib
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.
type EventListeners = { [T in NoVncEventType]?: (event: NoVncEvents[T]) => void };
interface Props {
url: string;
style?: object;
className?: string;
viewOnly?: boolean;
rfbOptions?: Partial<NoVncOptions>;
focusOnClick?: boolean;
clipViewport?: boolean;
dragViewport?: boolean;
scaleViewport?: boolean;
resizeSession?: boolean;
showDotCursor?: boolean;
background?: string;
qualityLevel?: number;
compressionLevel?: number;
autoConnect?: boolean;
retryDuration?: number;
debug?: boolean;
onConnect?: EventListeners['connect'];
onDisconnect?: EventListeners['disconnect'];
onCredentialsRequired?: EventListeners['credentialsrequired'];
onSecurityFailure?: EventListeners['securityfailure'];
onClipboard?: EventListeners['clipboard'];
onBell?: EventListeners['bell'];
onDesktopName?: EventListeners['desktopname'];
onCapabilities?: EventListeners['capabilities'];
onClippingViewport?: EventListeners['clippingviewport'];
}
// The types NoVncOptions, NoVncEventType and NoVncEvents are from the
// @novnc/novnc library.
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 ref
object has the following type:
type VncScreenHandle = {
connect: () => void;
disconnect: () => void;
connected: boolean;
sendCredentials: (credentials: NoVncOptions["credentials"]) => void;
sendKey: (keysym: number, code: string, down?: boolean) => void;
sendCtrlAltDel: () => void;
focus: () => void;
blur: () => void;
machineShutdown: () => void;
machineReboot: () => void;
machineReset: () => void;
clipboardPaste: (text: string) => void;
rfb: RFB | null;
loading: boolean;
eventListeners: EventListeners;
};
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.
See the open issues for a list of proposed features (and known issues).
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.
git checkout -b feature/AmazingFeature
)git commit -m 'feat: Add some AmazingFeature'
)git push origin feature/AmazingFeature
)You are requested to follow the contribution guidelines specified in CONTRIBUTING.md while contributing to the project :smile:.
Distributed under the MIT License. See LICENSE
for more information.
FAQs
A React Component to connect to a websockified VNC client using noVNC.
The npm package react-vnc receives a total of 6,239 weekly downloads. As such, react-vnc popularity was classified as popular.
We found that react-vnc demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.