Skip to content

Vizel API / vue/src / useVizelContextSafe

Function: useVizelContextSafe()

ts
function useVizelContextSafe(): 
  | ShallowRef<Editor | null>
  | null;

Defined in: packages/vue/src/components/VizelContext.ts:62

Composable to access the editor instance from VizelProvider context. Returns null if used outside a VizelProvider (does NOT throw).

Both useVizelContext and useVizelContextSafe return the underlying ShallowRef<Editor | null> so destructuring / template usage is symmetric; the only difference is whether the absence of a provider is treated as fatal.

Returns

| ShallowRef&lt;Editor | null&gt; | null

The injected editor ref, or null when no provider is present.

Released under the MIT License.