
Research
Supply Chain Attack on Axios Pulls Malicious Dependency from npm
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.
A React component for integrating ttyd web terminal with Xterm.js, supporting WebGL rendering and WebSocket connections
A React component for integrating ttyd web terminal with Xterm.js, supporting WebGL rendering and WebSocket connections.
npm install react-ttyd
or
yarn add react-ttyd
First, make sure you have a ttyd server running. Check ttyd for installation instructions.
# macOS
brew install ttyd
# Start ttyd
ttyd --writable bash
Then use the component in your React application:
import { Ttyd } from 'react-ttyd';
function App() {
return (
<Ttyd
wsUrl="ws://localhost:7681/ws"
clientOptions={{
rendererType: 'webgl'
}}
termOptions={{
fontSize: 14,
}}
/>
);
}
If your ttyd server requires authentication, you can provide credentials:
# Start ttyd with basic auth
ttyd --writable --credential testuser:testpw bash
<Ttyd
wsUrl="ws://localhost:7681/ws"
authToken={btoa('testuser:testpw')}
clientOptions={{
rendererType: 'webgl'
}}
/>
# Install ngrok
brew install ngrok
# Run ngrok
ngrok http 7681
| Prop | Type | Description | Default |
|---|---|---|---|
wsUrl | string | WebSocket URL of ttyd server | Required |
tokenUrl | string | URL to fetch auth token (if using token auth) | - |
authToken | string | Base64 encoded credentials for basic auth | - |
clientOptions | ClientOptions | Terminal client options | {} |
termOptions | ITerminalOptions | Xterm.js terminal options | {} |
onConnectionOpen | (event: Event) => void | WebSocket open callback | - |
onConnectionClose | (event: CloseEvent) => void | WebSocket close callback | - |
onConnectionError | (event: Event) => void | WebSocket error callback | - |
onData | (data: string) => void | Terminal data callback | - |
id | string | Terminal container element ID | - |
className | string | Terminal container CSS class | - |
addons | TerminalAddon[] | Additional Xterm.js addons | - |
| Option | Type | Description | Default |
|---|---|---|---|
rendererType | 'webgl' | 'canvas' | 'dom' | Renderer type | 'webgl' |
enableZmodem | boolean | Enable Zmodem support | false |
enableTrzsz | boolean | Enable trzsz support | false |
enableSixel | boolean | Enable Sixel support | false |
isWindows | boolean | Windows compatibility mode | Auto-detected |
unicodeVersion | '6' | '11' | Unicode version | '11' |
The termOptions prop accepts all Xterm.js terminal options.
Common options:
<Ttyd
wsUrl="ws://localhost:7681/ws"
termOptions={{
fontSize: 14,
fontFamily: 'Menlo, Monaco, "Courier New", monospace',
theme: {
background: '#1e1e1e',
foreground: '#ffffff'
},
cursorBlink: true,
cursorStyle: 'block'
}}
/>
This section is currently under development. More advanced features and examples will be added soon!
<Ttyd
wsUrl="ws://localhost:7681/ws"
authToken={btoa('testuser:testpw')}
/>
<Ttyd
wsUrl="ws://localhost:7681/ws"
authToken="your-auth-token"
/>
import { Terminal } from '@xterm/xterm';
import { MyCustomAddon } from './MyCustomAddon';
<Ttyd
wsUrl="ws://localhost:7681/ws"
addons={[new MyCustomAddon()]}
/>
<Ttyd
wsUrl="ws://localhost:7681/ws"
onConnectionOpen={(event) => {
console.log('Connected to ttyd server');
}}
onConnectionClose={(event) => {
console.log('Disconnected from ttyd server');
}}
onConnectionError={(event) => {
console.error('Connection error:', event);
}}
onData={(data) => {
console.log('Terminal output:', data);
}}
/>
Check out the example directory for a complete working example.
To run the example:
# Clone the repository
git clone https://github.com/tantara/react-ttyd.git
cd react-ttyd
# Install dependencies
npm install
# Build the library
npm run build
# Start ttyd server (in another terminal)
ttyd --writable bash
# Run the example
cd example/nextjs # or cd example/vite
npm install
npm run dev
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)This project is licensed under the MIT License - see the LICENSE file for details.
The following features from the original ttyd/html implementation are not yet ported to react-ttyd:
tokenUrl and refreshToken())closeOnDisconnect behaviorenableZmodem option)enableTrzsz option)enableSixel option)sendFile() functionalitydisableResizeOverlay option)disableLeaveAlert option)window.term object with fit() methodisWindows)FAQs
A React component for integrating ttyd web terminal with Xterm.js, supporting WebGL rendering and WebSocket connections
We found that react-ttyd 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
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.

Security News
TeamPCP is partnering with ransomware group Vect to turn open source supply chain attacks on tools like Trivy and LiteLLM into large-scale ransomware operations.