Function setContext

  • Associates an arbitrary context object with the current component and the specified key and returns that object. The context is then available to children of the component (including slotted content) with getContext.

    Like lifecycle functions, this must be called during component initialisation.

    https://svelte.dev/docs/svelte#setcontext

    Type Parameters

    • T

    Parameters

    • key: any
    • context: T

    Returns T