Hooks

useWidgetState

ChatGPT hook from moonpeak/chatgpt.

View .mdEdit on GitHub
import { useWidgetState } from "moonpeak/chatgpt";

useWidgetState<S>(): [S | undefined, (v: S) => void]

ChatGPT's raw widget state. Prefer useAppState, which uses it in ChatGPT and works in every other host too.

Example

const [saved, save] = useWidgetState<{ tab: number }>();

Works in

ChatGPT. Safe to call anywhere: elsewhere it returns an empty value or does nothing.

See all hooks in Runtime APIs.