useSwContext()
WARNING
Single File Component (SFC) support for Administration extensions is experimental. It is available since Shopware 6.7.16.0. The APIs described on this page can still change without a deprecation. Try it out and tell us what you find, but do not ship an extension built on it to customers or to the Shopware Store until the API is declared stable (planned for 6.9).
ts
function useSwContext<T = SetupContext>(): T;Provided by the build in every .override.vue file; you never import it. Returns the overridden component's Vue SetupContext: emit, attrs, slots and expose.
ts
const context = useSwContext();
const previousState = useSwPreviousState();
function onSave(): void {
previousState.onSave();
context.emit('saved');
}Use it to emit the component's own events from an override, or to read the slots it was given.
A base component does not need this: it declares its events with defineEmits() and its slots with defineSlots().