function useWebContext()
Initializes the web application context with renderer, viewport, and navigation.
function useWebContext(
config?: (opts: WebContextOptions) => void,
): AppContext;
Notes
- Clears any existing context using AppContext.clear() before initialization.
- Applies a default theme automatically; use setWebTheme() in the callback to customize.
- Sets up automatic dark mode handling when the system color scheme changes.
Parameters
- config — A callback to configure options and apply a custom theme.
Return value
The global app context.
Description
Call this function once at application startup to configure the web handler. It can also be called again to reset application state, for example after logging out the current user.
Examples
// Start the application with default theme
const app = useWebContext();
app.addActivity(new MyActivity());
// Start with custom theme
const app = useWebContext(() => {
setWebTheme(new WebTheme()
.colors({ accent: "#FF5722" })
.darkColors({ accent: "#FF7043" })
);
});
