fn

setActiveApp

v0.1.0testeddemo

Registers the Vue app instance used by getActiveApp, runWithApp and injectWithApp outside of component context. Pass undefined to clear the registration. The registration is module-global (one slot per JS realm). On the client this is exactly what you want; on the server create one app per request and prefer passing the app explicitly to runWithApp instead of relying on the global slot, otherwise concurrent requests may observe each other's app.

Example

ts
// main.ts
const app = createApp(App);
setActiveApp(app);

Demo

Loading demo…

Signature

ts
export function setActiveApp(app: App | undefined){ ... }

Parameters

ParameterTypeDescription
appApp | undefinedThe app to register, or undefined to clear

Returns

App<any> | undefinedThe same app, for chaining