Level 102
Before inertia version 1 it was called Inertia not router
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I would like to use the follow code found on https://inertiajs.com/events
import { router } from '@inertiajs/vue3'
router.on('before', (event) => {
if (!confirm('Are you sure you want to navigate away?')) {
event.preventDefault()
}
})
I have not upgraded to the latest version of inertia. In my .vue files I have
//my .vue files
import { router } from '@inertiajs/inertia-vue3
which is different from the docs
//docs
import { router } from '@inertiajs/vue3'
//The error is
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'on')
Does this mean I have to upgrade Inertia? That sounds difficult and scary. I would like to complete the project and then consider upgrading.
Obviously being the cunning man that I am I tried router.value.on() which made me feel retarded but I just wanted to note that I did try it.
Before inertia version 1 it was called Inertia not router
Please or to participate in this conversation.