Skip to content
masterclass Buddy

Vue.js · Function

inject

inject() gets a dependency provided by an ancestor or the app. It looks up the value by a string or Symbol key and can use a default when no provider exists.

Last updated

Syntax

inject(key, defaultValue?, treatDefaultAsFactory?)

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

Subscribe
  • provide
  • readonly
  • computed
  • ref
  • Symbol

Source: Provide / Inject | Vue.js. Checked 2026-11-03.