Xterm.js is a front-end component written in TypeScript that lets applications bring fully-featured terminals to their users in the browser. It’s used by popular projects such as VS Code, Hyper and Theia.
Terminal apps just work: Xterm.js works with most terminal apps such as bash, vim and tmux, this includes support for curses-based apps and mouse event support
Performant: Xterm.js is really fast, it even includes a GPU-accelerated renderer
Rich unicode support: Supports CJK, emojis and IMEs
Self-contained: Requires zero dependencies to work
Accessible: Screen reader support can be turned on using the screenReaderMode option
And much more: Links, theming, addons, well documented API, etc.
First you need to install the module, we ship exclusively through npm so you need that installed and then add xterm.js as a dependency by running:
npm install xterm
To start using xterm.js on your browser, add the xterm.js and xterm.css to the head of your html page. Then create a <div id="terminal"></div> onto which xterm can attach itself. Finally instantiate the Terminal object and then call the open function with the DOM object of the div.
<!doctype html><html><head><linkrel="stylesheet"href="node_modules/xterm/css/xterm.css"/><script src="node_modules/xterm/lib/xterm.js"></script></head><body><divid="terminal"></div><script>varterm=newTerminal();term.open(document.getElementById('terminal'));term.write('Hello from \x1B[1;3;31mxterm.js\x1B[0m $ ')</script></body></html>
Xterm.js is used in several world-class applications to provide great terminal experiences.
SourceLair: In-browser IDE that provides its users with fully-featured Linux terminals based on xterm.js.
Microsoft Visual Studio Code: Modern, versatile and powerful open source code editor that provides an integrated terminal based on xterm.js.
ttyd: A command-line tool for sharing terminal over the web, with fully-featured terminal emulation based on xterm.js.
Katacoda: Katacoda is an Interactive Learning Platform for software developers, covering the latest Cloud Native technologies.