N
Nuxt4mo ago
Omnislash

toRefs() error since update

Hello Kapa (or others ^^) I have this error since I ncu -u my project :
toRefs() expects a reactive object but received a plain one
toRefs() expects a reactive object but received a plain one
I don't use toRefs(), couldn't find any occurencies with a research. So I bet on the ncu -u. Here is my package.json :
{
"name": "nuxt-base",
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare",
"lint": "eslint .",
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@nuxt/eslint": "^1.4.1",
"@nuxt/icon": "^1.13.0",
"@nuxt/image": "^1.10.0",
"@nuxt/scripts": "^0.11.7",
"@nuxt/ui": "^3.1.3",
"@nuxtjs/device": "^3.2.4",
"@nuxtjs/i18n": "^9.5.5",
"@nuxtjs/seo": "^3.0.3",
"@unhead/vue": "^2.0.10",
"luxon": "^3.6.1",
"nuxt": "^3.17.4",
"tailwindcss": "^4.1.8",
"vue": "latest",
"vue-router": "latest",
"zod": "^3.25.42"
},
"volta": {
"node": "22.14.0",
"npm": "11.1.0"
},
"devDependencies": {
"@iconify-json/lucide": "^1.2.45",
"@iconify-json/ri": "^1.2.5",
"@types/luxon": "^3.6.2"
}
}
{
"name": "nuxt-base",
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare",
"lint": "eslint .",
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@nuxt/eslint": "^1.4.1",
"@nuxt/icon": "^1.13.0",
"@nuxt/image": "^1.10.0",
"@nuxt/scripts": "^0.11.7",
"@nuxt/ui": "^3.1.3",
"@nuxtjs/device": "^3.2.4",
"@nuxtjs/i18n": "^9.5.5",
"@nuxtjs/seo": "^3.0.3",
"@unhead/vue": "^2.0.10",
"luxon": "^3.6.1",
"nuxt": "^3.17.4",
"tailwindcss": "^4.1.8",
"vue": "latest",
"vue-router": "latest",
"zod": "^3.25.42"
},
"volta": {
"node": "22.14.0",
"npm": "11.1.0"
},
"devDependencies": {
"@iconify-json/lucide": "^1.2.45",
"@iconify-json/ri": "^1.2.5",
"@types/luxon": "^3.6.2"
}
}
Any idea why ?
5 Replies
kapa.ai
kapa.ai4mo ago
Hi @Omnislash. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The error message:
toRefs() expects a reactive object but received a plain one
toRefs() expects a reactive object but received a plain one
typically means that somewhere in your code (or a dependency), toRefs() is being called on a plain object instead of a reactive one. Even if you don't directly use toRefs(), it could be used in a composable, a third-party module, or a dependency that was updated during your ncu -u upgrade. This issue is commonly seen after upgrading Nuxt or related dependencies, as stricter checks or breaking changes may have been introduced in the reactivity system. For example, in Vue 3 and Nuxt 3, toRefs() should only be used on objects returned by reactive() or similar APIs, not on plain objects or props directly. Relevant context from the knowledge sources: - A similar error is discussed in the context of using toRefs() on props or plain objects, which leads to loss of reactivity or errors. The solution is to ensure you only use toRefs() on reactive objects, such as those created by reactive() or returned from defineProps() in <script setup>. For example, you can do:
const props = defineProps({ ... })
const { fruit } = toRefs(props)

const props = defineProps({ ... })
const { fruit } = toRefs(props)

or, if you want to make a reactive copy:
const dataInput = reactive(toRefs(props))
const { data, error, pending } = await useGetData(toRefs(dataInput))

const dataInput = reactive(toRefs(props))
const { data, error, pending } = await useGetData(toRefs(dataInput))

This ensures reactivity is preserved and avoids the error you are seeing if the object is not reactive to begin with How to pass a reactive object with prop values from a component to a composable in vue3 / nuxt3, Vue3 / Nuxt3 - how to use props directly in setup. - If you recently upgraded Nuxt or related packages, breaking changes in the reactivity system or stricter type checks could be the cause. Double-check any composables or modules that might use toRefs() internally, especially if they expect a reactive object but now receive a plain one after the upgrade. What you can do: 1. Search your codebase (including node_modules if possible) for toRefs() usage. 2. Check any custom composables or third-party modules that may have changed after the upgrade. 3. If you find a usage of toRefs() on a plain object, refactor it to ensure the object is reactive (e.g., wrap it with reactive() if appropriate). 4. If the issue is in a third-party module, check if there's an update or open issue addressing this compatibility. If you need more specific help, try to identify which file or module the error is coming from (the stack trace should help). If it's from a dependency, you may need to wait for an upstream fix or temporarily pin to an earlier version. Let me know if you can provide a stack trace or more context, and I can help you narrow it down further! ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4mo ago
<@305772639438503936> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Omnislash
OmnislashOP4mo ago
@kapa.ai I have no usage of toRefs Can you tell from my package.json if there is any version issue causing this warning ?
kapa.ai
kapa.ai4mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- Based on the knowledge sources provided, there is no explicit mention of the toRefs() error being caused by a specific version in your package.json. The sources do discuss various issues related to Nuxt 3.17.x releases, such as problems with stylesheets, fonts, and some module incompatibilities, but none directly reference a toRefs() error or a breaking change in Vue or Nuxt that would cause this error after upgrading dependencies in the way you describe. The knowledge sources do not contain enough information to definitively identify a version in your package.json as the cause of the toRefs() warning. If the error persists and you suspect it is related to a recent upgrade, you may want to check the changelogs of your dependencies or try reverting to previous versions incrementally to isolate the cause. If you can provide a stack trace or more context about where the error is thrown, it may help narrow down the issue. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4mo ago
<@305772639438503936> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?