\n\n### Reproduction\n\nhttps://stackblitz.com/edit/vitejs-vite-m1bs1kix?file=src%2FApp.vue\n\n### System Info\n\n```Shell\nSystem:\n OS: Windows 11 10.0.22631\n CPU: (16) x64 AMD Ryzen 7 8845HS w/ Radeon 780M Graphics\n Memory: 12.32 GB / 31.31 GB\nBinaries:\n Node: 22.15.1 - D:\\Program Files\\nodejs\\node.EXE\n npm: 10.9.2 - D:\\Program Files\\nodejs\\npm.CMD\n pnpm: 10.12.2 - D:\\Program Files\\nodejs\\pnpm.CMD\nBrowsers:\n Edge: Chromium (127.0.2651.98)\n Internet Explorer: 11.0.22621.3527\nnpmPackages:\n @vueuse/core: ^13.4.0 => 13.4.0\n vue: v3.6.0-alpha.1 => 3.6.0-alpha.1\n```\n\n### Used Package Manager\n\npnpm\n\n### Validations\n\n- [x] Follow our [Code of Conduct](https://github.com/vueuse/vueuse/blob/main/CODE_OF_CONDUCT.md)\n- [x] Read the [Contributing Guidelines](https://github.com/vueuse/vueuse/blob/main/CONTRIBUTING.md).\n- [x] Read the [docs](https://vueuse.org/guide).\n- [x] Check that there isn't [already an issue](https://github.com/vueuse/vueuse/issues) that reports the same bug to avoid creating a duplicate.\n- [x] Make sure this is a VueUse issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead.\n- [x] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/vueuse/vueuse/discussions).\n- [x] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.",[3018],{"name":3019,"color":3020},"pending triage","d73a4a",4875,"vueuse","open","BUG | `provideLocal` and `injectLocal` | In Vue's vapor mode, `getCurrentInstance` returns `null`","2025-07-14T06:38:22Z","https://github.com/vueuse/vueuse/issues/4875",0.68862355,{"description":3029,"labels":3030,"number":1913,"owner":3022,"repository":3031,"state":3032,"title":3033,"updated_at":3034,"url":3035,"score":3036},"Hi @antfu, big thanks for providing Vue Demi.\r\n\r\nSince the breaking change introduced in [Vue Composition API 1.0.0-beta.22](https://github.com/vuejs/composition-api/blob/master/CHANGELOG.md#100-beta22-2020-12-19) `getCurrentInstance` only works with the following workaround in Vue 3:\r\n\r\n```\r\nconst vm = isVue3 ? getCurrentInstance() : getCurrentInstance().proxy\r\nconst lazy = vm.attrs.modelModifiers.lazy // will crash with getCurrentInstance().proxy\r\n```",[],"vue-demi","closed","getCurrentInstance broken with Vue Composition API 1.0.0-beta.22","2020-12-24T14:07:30Z","https://github.com/vueuse/vue-demi/issues/23",0.6443355,{"description":3038,"labels":3039,"number":3040,"owner":3022,"repository":3031,"state":3032,"title":3041,"updated_at":3042,"url":3043,"score":3044},"\r\n\r\n\r\nWhen using in Vue 2.6, the hasInjectionContext method will be executed. At this point, the default method exposed by VueCompositionAPI is only install. You need to selectively import getCurrentInstance.",[],231,"Vue 2.6: Error \"VueCompositionAPI.getCurrentInstance is not a function\" in hasInjectionContext()","2023-05-18T10:21:16Z","https://github.com/vueuse/vue-demi/issues/231",0.6924156,{"description":3046,"labels":3047,"number":3048,"owner":3022,"repository":3031,"state":3032,"title":3049,"updated_at":3050,"url":3051,"score":3052},"For some reason, Vuelidate's `useVuelidate()` function crashes on `vue-demi`'s `getCurrentInstance()`, but only in Codesandbox (with Vue 2 only) and StackBlitz (any version of Vue).\r\n\r\nI initially opened a [Vuelidate issue](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/canplaythrough_event), but they [punted to `vue-demi`](https://github.com/vuelidate/vuelidate/issues/877#issuecomment-859998691).\r\n\r\n---\r\n\r\nFollowing the [guide for using Vuelidate with Composition API](https://vuelidate-next.netlify.app/#alternative-syntax-composition-api), I'm seeing an error when `useVuelidate()` is called:\r\n\r\n```\r\nindex.js:27 TypeError: (0 , $csb__vuedemi.getCurrentInstance) is not a function\r\n```\r\n\r\nThis seems to occur only in Codesandbox or StackBlitz. Running the same code in a Vue CLI scaffolded project works fine.\r\n\r\n\u003Cdetails>\r\n\u003Csummary>Stack trace\u003C/summary>\r\n\u003Cpre>\r\nindex.js:27 TypeError: (0 , $csb__vuedemi.getCurrentInstance) is not a function\r\n at useVuelidate (index.esm.js:580)\r\n at setup (App.vue:32)\r\n at mergedSetupFn (vue-composition-api.esm.js:1957)\r\n at eval (vue-composition-api.esm.js:1770)\r\n at activateCurrentInstance (vue-composition-api.esm.js:1708)\r\n at initSetup (vue-composition-api.esm.js:1769)\r\n at VueComponent.wrappedData (vue-composition-api.esm.js:1756)\r\n at getData (vue.common.dev.js:4754)\r\n at initData (vue.common.dev.js:4711)\r\n at initState (vue.common.dev.js:4650)\r\n at VueComponent.Vue._init (vue.common.dev.js:5010)\r\n at new VueComponent (vue.common.dev.js:5157)\r\n at createComponentInstanceForVnode (vue.common.dev.js:3307)\r\n at init (vue.common.dev.js:3136)\r\n at createComponent (vue.common.dev.js:6013)\r\n at createElm (vue.common.dev.js:5960)\r\n at Vue.patch [as __patch__] (vue.common.dev.js:6549)\r\n at Vue._update (vue.common.dev.js:3957)\r\n at Vue.updateComponent (vue.common.dev.js:4078)\r\n at Watcher.get (vue.common.dev.js:4490)\r\n at new Watcher (vue.common.dev.js:4479)\r\n at mountComponent (vue.common.dev.js:4085)\r\n at Vue.$mount (vue.common.dev.js:9084)\r\n at Vue.$mount (vue.common.dev.js:11989)\r\n at evaluate (main.js? [sm]:9)\r\n at V (eval.js:42)\r\n at ee.evaluate (transpiled-module.js:699)\r\n at ge.evaluateTranspiledModule (manager.js:297)\r\n at ge.evaluateModule (manager.js:268)\r\n at compile.ts:728\r\n at c (runtime.js:45)\r\n at Generator._invoke (runtime.js:274)\r\n at Generator.forEach.t.\u003Ccomputed> [as next] (runtime.js:97)\r\n at r (asyncToGenerator.js:3)\r\n at u (asyncToGenerator.js:25)\r\n\u003C/pre>\r\n\u003C/details>\r\n\r\n**Reproduction URL**\r\nhttps://codesandbox.io/s/usevuelidate-bug-getcurrentinstance-is-not-a-function-6rx9w\r\n\r\nor\r\n\r\nhttps://stackblitz.com/edit/vuelidate-bug-demo\r\n\r\n**To Reproduce**\r\nSteps to reproduce the behavior:\r\n1. Create new [Codesandbox for Vue 2](https://vue.new) (or fork [Vuelidate's official Vue 3 + Composition API Starter](https://codesandbox.io/s/vuelidate-2-composition-api-vue-3-7wf99) and switch Vue version to 2.x).\r\n2. Add dependency for `@vue/composition-api`, and install it from `main.js`:\r\n\r\n ```js\r\n import VueCompositionApi from '@vue/composition-api'\r\n Vue.use(VueCompositionApi)\r\n ```\r\n\r\n3. Open `src/App.vue`, and copy [Vuelidate guide's example code for the Composition API usage](https://vuelidate-next.netlify.app/#alternative-syntax-composition-api):\r\n\r\n ```js\r\n import { reactive, toRefs } from '@vue/composition-api'\r\n import useVuelidate from '@vuelidate/core'\r\n import { required, email } from '@vuelidate/validators'\r\n\r\n export default {\r\n setup () {\r\n const state = reactive({\r\n firstName: '',\r\n lastName: '',\r\n contact: {\r\n email: ''\r\n }\r\n })\r\n const rules = {\r\n firstName: { required }, // Matches state.firstName\r\n lastName: { required }, // Matches state.lastName\r\n contact: {\r\n email: { required, email } // Matches state.contact.email\r\n }\r\n }\r\n\r\n const v$ = useVuelidate(rules, state)\r\n\r\n return { ...toRefs(state), v$ }\r\n }\r\n }\r\n ```\r\n\r\n4. See error in browser console\r\n\r\n**Expected behavior**\r\nThe same output from [Vuelidate's official Vue 3 + Composition API Starter](https://codesandbox.io/s/vuelidate-2-composition-api-vue-3-7wf99).\r\n\r\n**Screenshots**\r\n\u003Cimg width=\"469\" alt=\"Screen Shot 2021-06-11 at 10 14 50 PM\" src=\"https://user-images.githubusercontent.com/26580/121763534-7815cd80-cb02-11eb-924e-c4402978d976.png\">\r\n\r\n\r\n**Additional context**\r\n\r\n * `vue` 2.6.14\r\n * `@vue/composition-api` 1.0.0-rc.11\r\n * `@vuelidate/core` 2.0.0-alpha.14 (also newer versions, including 2.0.0-alpha.19)\r\n * `@vuelidate/validators` 2.0.0-alpha.12 (also newer versions, including 2.0.0-alpha.17)\r\n * macOS BigSur\r\n * Chrome 91\r\n * StackBlitz (version unknown, but as of 11-Jun-2021)\r\n * CodeSandbox a566285e0\r\n",[],68,"\"getCurrentInstance is not a function\" in Codesandbox/StackBlitz","2021-07-15T17:21:06Z","https://github.com/vueuse/vue-demi/issues/68",0.7117802,{"description":3054,"labels":3055,"number":3056,"owner":3022,"repository":3031,"state":3032,"title":3057,"updated_at":3058,"url":3059,"score":3060},"问题1: 一个vue3的组件在vue3环境下打包后的 在vue3的demo中使用组件样式未生效,getCurrentInstance获得的是null\r\n` import {\r\n defineComponent,\r\n ref,\r\n Vue2,\r\n isVue2,\r\n isVue3,\r\n getCurrentInstance,\r\n createVNode,\r\n render\r\n } from 'vue-demi';\r\n // import { createVNode, render } from 'vue'; // 若使用demo环境中的vue样式是生效的\r\n import Card from './card.vue';\r\n\r\n export default defineComponent({\r\n setup(props, context) {\r\n const btnFun = () => {\r\n cardShow();\r\n };\r\n\r\n const cardShow = () => {\r\n const node = document.getElementById('game-card');\r\n if (!node) {\r\n // 在vue2环境没有问题\r\n if (isVue2) {\r\n const gameCardComponent = Vue2.extend(Card);\r\n const gameCardInstance = new gameCardComponent({\r\n propsData: {\r\n btnObj: this\r\n }\r\n }).$mount();\r\n document.body.appendChild(gameCardInstance.$el);\r\n }\r\n if (isVue3) {\r\n const instance = getCurrentInstance();\r\n console.log(instance); // 打印为null\r\n const gameCardComponent = createVNode(Card, {\r\n btnObj: instance\r\n });\r\n render(gameCardComponent, document.querySelector('body'));\r\n }\r\n }\r\n };\r\n\r\n return {\r\n button_name,\r\n btnFun\r\n };\r\n }\r\n });`\r\n\r\n问题2: 一个vue3的组件在vue2环境下使用打包后的 在vue2的demo中\r\n\r\n",[],194,"在'vue-demi'中可以导出createVNode, render, getCurrentInstance这些vue3的方法使用吗?","2022-08-30T02:36:24Z","https://github.com/vueuse/vue-demi/issues/194",0.7236017,{"description":3054,"labels":3062,"number":3063,"owner":3022,"repository":3031,"state":3032,"title":3057,"updated_at":3064,"url":3065,"score":3060},[],195,"2022-08-26T12:48:02Z","https://github.com/vueuse/vue-demi/issues/195",{"description":3067,"labels":3068,"number":3069,"owner":3022,"repository":3022,"state":3032,"title":3070,"updated_at":3071,"url":3072,"score":3073},"get vue [Global config](https://v3.vuejs.org/api/application-config.html#globalproperties)\r\n\r\nsimple code demo:\r\n\r\n```\r\nimport { getCurrentInstance } from 'vue'\r\nexport function useGlobalConfig(key) {\r\n const vm: any = getCurrentInstance()\r\n if (key in vm.proxy) {\r\n return vm.proxy.key\r\n }\r\n return {}\r\n}\r\n```",[],261,"add useGlobalConfig suggestion","2020-12-22T06:48:04Z","https://github.com/vueuse/vueuse/issues/261",0.72594476,{"description":3075,"labels":3076,"number":3077,"owner":3022,"repository":3031,"state":3032,"title":3078,"updated_at":3079,"url":3080,"score":3081},"vuelidate is using vue-demi to help them with their new version support both Vue 2 and Vue 3. They need access to the equivalent of the Plugin. This is a new type in Vue 3 and should have an equivalent in Vue 2. \r\n\r\nIs there a way that Vue-demi could provide a common abstraction? \r\nHere is the open in issue on vuelidate\r\nhttps://github.com/vuelidate/vuelidate/issues/767\r\n",[],32,"vue-demi doesn't include Plugin export","2021-07-15T17:17:11Z","https://github.com/vueuse/vue-demi/issues/32",0.7275582,{"description":3083,"labels":3084,"number":3085,"owner":3022,"repository":3022,"state":3032,"title":3086,"updated_at":3087,"url":3088,"score":3089},"I just installed your package v6.2.1 since you released it 9 minutes ago.\r\n\r\nWhen I try to use the version v6.2.1, Webpack returns the following error:\r\n>ModuleDependencyError: export 'effectScope' (imported as 'effectScope') was not found in 'vue-demi' \r\n\r\nInstalling the previous version (v6.2.0) make it works. So I suppose it is a regression.",[],721,"Bug: v6.2.1 does not build","2021-09-07T14:11:20Z","https://github.com/vueuse/vueuse/issues/721",0.728431,{"description":3091,"labels":3092,"number":3093,"owner":3022,"repository":3031,"state":3032,"title":3094,"updated_at":3095,"url":3096,"score":3097},"Hello @antfu,\r\n\r\nunfortunately I can not use `vue-demi` in a micro frontend setup, where the container SPA provides the vue instance via `window.Vue`. The web components are using `vue-demi` but they crash since it tries to install the composition api on a non existing Vue instance.\r\n\r\n> [vue-composition-api] No vue dependency found. (in getRegisteredVueOrDefault)\r\n\r\nis there any workaround to make this default `install(Vue)` call optional?",[],46,"Add support for web-components","2021-03-10T22:05:24Z","https://github.com/vueuse/vue-demi/issues/46",0.7286544,["Reactive",3099],{},["Set"],["ShallowReactive",3102],{"$fTRc1wZytZ_XrK4EfJfei_Sz-An4H4Yy6syhVxH_PVJc":-1,"$fEexcpQrIf1BFjL37l3Zp_ISaBaeIkzZuUTDd3SB5ZP0":-1},"/vueuse/vue-demi/267"]