Hooks

useConnection

Host hook from moonpeak.

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

useConnection(): { status: "connecting" | "ready" | "error"; error; ready: boolean }

State of the postMessage connection to the host.

Example

const { ready, error } = useConnection();
if (error) return <p>Could not reach the host.</p>;

Works in

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

See all hooks in Runtime APIs.