Hooks

useContainerSize

Host context hook from moonpeak.

View .mdEdit on GitHub
import { useContainerSize } from "moonpeak";

useContainerSize(): { width?; height?; maxWidth?; maxHeight? }

The space the host gives the View, as reported in host context.

Example

const { width } = useContainerSize();
const columns = (width ?? 600) > 520 ? 7 : 4;

Works in

Every MCP Apps host: ChatGPT, Claude, VS Code, Goose and the moonpeak inspector.

See all hooks in Runtime APIs.