The connected App instance, or null during initialization
OptionalinitialContext: McpUiHostContext | nullInitial host context from the connection (optional). If provided, fonts will be applied immediately on mount.
function MyApp() {
const { app } = useApp({
appInfo: { name: "MyApp", version: "1.0.0" },
capabilities: {},
});
// Apply host fonts - pass initial context to apply fonts from connect() immediately
useHostFonts(app, app?.getHostContext());
return <div style={{ fontFamily: "var(--font-sans)" }}>Hello!</div>;
}
applyHostFonts for the underlying fonts functionuseHostStyleVariables for applying style variables and theme
React hook that applies host fonts from CSS.
This hook listens to host context changes and automatically applies:
styles.css.fontsas a<style>tag for custom fontsThe CSS can contain
@font-facerules for self-hosted fonts,@importstatements for Google Fonts or other font services, or both.The hook also applies fonts from the initial host context when the app first connects.