Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vue 3: Is getCurrentInstance() deprecated?

Tags:

vue.js

vuejs3

I've seen references to getCurrentInstance() function on some old(?) documents and codes, but cannot find it in the current Vue 3 document.

Is getCurrentInstance() deprecated?

If so, what is the reason? (inject() considered enough?) If not, why can't I find it in the document?

like image 919
zeodtr Avatar asked Dec 06 '25 10:12

zeodtr


1 Answers

getCurrentInstance() was removed from the Vue 3 docs because it's an internal API:

Because the instance is an internal instance that exposes non-public APIs. Anything you use from that instance can technically break between any release types, since they are not subject to semver constraints.


getCurrentInstance() was originally documented in 4-Oct-2020, but that was later removed in 31-Aug-2021 in a major refactoring of the Composition API docs by the creator of Vue (Evan You). Despite its removal from the docs, getCurrentInstance() still:

  • is widely used in Vue core.

  • is not documented as deprecated in code.

  • is exported as part of the Advanced API.

Given that it's an undocumented internal API, use it with caution.

like image 156
tony19 Avatar answered Dec 08 '25 01:12

tony19