Overview
TheuseApp hook returns the App instance from the nearest AppProvider. Use this when you need direct access to the App for SDK method calls like app.requestDisplayMode(). Most hooks read from context internally, so you typically only need useApp() for direct SDK calls.
The AppProvider handles connecting to the MCP Apps host, HMR persistence during development, and React StrictMode compatibility. It is set up automatically by the sunpeak framework — you never need to write it yourself.
Import
Signature
Returns
The connected App instance, or
null while connecting.Usage
AppProvider
TheAppProvider component wraps your resource component tree and establishes the connection to the MCP Apps host. It is added automatically by the sunpeak framework in both dev and production builds.
Props
App identification information sent to the host.
Capabilities to advertise to the host. Optional.
Callback invoked when a new App instance is created. Optional.