Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincej's avatar
Level 15

Inertia 1.0 : How to return data back to controller from Page view

I am trying to pass data back to my controller. I have installed the new Inertia 1.0 . To that end I have entered into the script, import router from '@inertiajs/vue3'. According Jeffrey's tutorial on inertia all should have to do is import inertia into my Vue 3 script and then do an Inertia.post(),

If you use Inertia.post() you get an error in he Chrome console :

Uncaught ReferenceError: Inertia is not defined

So, I changed it to router.post() however, with the new router function nothing is working. I get an error,

export 'default' (imported as 'router') was not found in '@inertiajs/vue3' (possible exports: Head, Link, createInertiaApp, router, useForm, usePage, useRemember)

I post my code below. FYI I am getting all the data through on this.changedChild

Any ideas?? Many thanks!

    <script>
    import router from '@inertiajs/vue3'

    export default {

        props: {
            Children:{
                Children:Array
             },
        },

        data() {
            return {
                active:false,
                inputClass: 'present',
                absentPresent:'Absent/Present'
            }

        },

        methods:{
            updateChild(child){
                this.changedChild = child;
                console.log( this.changedChild);
                this.inputClass = 'present'
                this.active = ! this.active
             
		   Inertia.post('/updateChild',this.changedChild)    // THIS DOES NOT WORK
            },
        },
    }
    </script>

0 likes
9 replies
JeffreyWay's avatar

@vincej You're importing the router incorrectly. Do:

import { router } from "@inertiajs/vue3";
vincej's avatar
Level 15

@JeffreyWay Thanks for that Jeffrey! I fixed the import statement, However, I am still getting an error in the Chrome console:

runtime-core.esm-bundler.js?d2dd:220 Uncaught ReferenceError: Inertia is not defined

When I do the Inertia.post('/updateChild',this.changedChild) in the above code. Everything else in Inertia is working and I did update my app.js to the new Inertia 1.0. What am I missing?

vincej's avatar
Level 15

@jlrdw Like how? this required route is inside a Vue3 component.

vincej's avatar
Level 15

@jlrdw I guess I could use raw JS, but then I am abandoning the benefits of Inertia ie I would have to build an api etc.

vincej's avatar
Level 15

@jlrdw You are a rock star! Of course - Inertia has only just this week changed some of it's code and indeed Jeffrey's tutorials have not yet caught up ... but if only I had the sense to check the docs! Stupid me. I can not thank you enough!!

Sinnbeck's avatar

@vincej you need to change Inertia as well. It's that import you changed

Inertia.post('/updateChild',this.changedChild) //before v1
router.post('/updateChild',this.changedChild) //after v1
1 like

Please or to participate in this conversation.