Skip to content
masterclass Buddy

Vue.js · Function

provide

provide() makes a value available to descendant components. inject() retrieves it by key, including values provided at app level.

Last updated

Syntax

provide<T>(key: InjectionKey<T> | string, value: T): void
inject<T>(key: InjectionKey<T> | string, defaultValue?: T): T | undefined
inject<T>(key: InjectionKey<T> | string, defaultValue: () => T, treatDefaultAsFactory: true): T

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • inject()
  • app.provide()
  • InjectionKey
  • readonly()
  • computed()
  • hasInjectionContext()

Source: Composition API: Dependency Injection | Vue.js. Checked 2026-11-03.