File: use-stdin.md | Updated: 11/16/2025
useStdin is a React hook that exposes the stdin stream.
import {useStdin} from 'ink';
const Example = () => {
const {stdin} = useStdin();
return …
};
Type: stream.Readable
Default: process.stdin
The stdin stream passed to render() in options.stdin, or process.stdin by default.
Useful if your app needs to handle user input.
Type: boolean
A boolean flag determining if the current stdin supports setRawMode.
A component using setRawMode might want to use isRawModeSupported to nicely fall back in environments where raw mode is not supported.
import {useStdin} from 'ink';
const Example = () => {
const {isRawModeSupported} = useStdin();
return isRawModeSupported ? (
<MyInputComponent />
) : (
<MyComponentThatDoesntUseInput />
);
};
Type: function
Type: boolean
See setRawMode.
Ink exposes this function to be able to handle <kbd>Ctrl</kbd>+<kbd>C</kbd>, that's why you should use Ink's setRawMode instead of process.stdin.setRawMode.
Warning: This function will throw unless the current stdin supports setRawMode. Use isRawModeSupported to detect setRawMode support.
import {useStdin} from 'ink';
const Example = () => {
const {setRawMode} = useStdin();
useEffect(() => {
setRawMode(true);
return () => {
setRawMode(false);
};
});
return …
};