Docs (4.0.0)
Web context

useWebContext

Clears the current global app context and initializes a web context.

useWebContext(config?: ConfigOptions.Arg<WebContextOptions>): WebContext

Notes

  • This method must be used to set up a Desk web application. It can also be used to clear the state of the current application, e.g. after logging out the current user or applying global settings.
  • Before initializing a new context, the GlobalContext.clear() method is used to reset the current context, if any.

Parameters

Return value

The app global context, typed as WebContext.

Example

// Start the application
const app = useWebContext((options) => {
  options.logicalPxScale = 1.5;
  options.theme.styles.LinkButton =
    options.theme.styles.LinkButton.extend({
      decoration: { borderColor: ui.color.PRIMARY },
    });
});
app.addActivity(new MyActivity())
app.addService("MyService", new MyService())