📄 ink/hooks/use-stderr

File: use-stderr.md | Updated: 11/16/2025

useStderr

useStderr is a React hook that exposes the stderr stream.

Usage

import {useStderr} from 'ink';

const Example = () => {
	const {stderr} = useStderr();

	return …
};

API

stderr

Type: stream.Writable
Default: process.stderr

Stderr stream.

write(data)

Write any string to stderr while preserving Ink's output.

It's useful when you want to display external information outside of Ink's rendering and ensure there's no conflict between the two. It's similar to <Static>, except it can't accept components; it only works with strings.

data

Type: string

Data to write to stderr.

Example

import {useStderr} from 'ink';

const Example = () => {
	const {write} = useStderr();

	useEffect(() => {
		// Write a single message to stderr, above Ink's output
		write('Hello from Ink to stderr\n');
	}, []);

	return …
};