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

cib88's avatar
Level 2

Access root props interia.js

I have a form that once submitted successfully needs to display a thank you message. If all validation passes in my controller then I return to the current component with a message like so.

return Inertia('Home', [
    'message' => 'Your contribution was successful, thank you.',
]);

I took this from https://inertiajs.com/responses however I can't seem to access the message. If I check the network tab once the form has been submitted I can see in the props object my message is there

{
    "errors": {},
    "auth": {
        "user": null
    },
    "message": "Your contribution was successful, thank you."
}

But I can't get it to display I pass the message into my component like this

interface Props {
    message?: string;
}
export default ({ message }: Props) => {
...
}

and display it like {message && <p>{message}</p>}

0 likes
1 reply
cib88's avatar
cib88
OP
Best Answer
Level 2

Not sure if it's the correct way to do this but I discovered if I changed my post request from

Inertia.post("/", {
    preserveScroll: true,
});

to

post("/", {
    preserveScroll: true,
});

and now the message is displayed when the form is submitted.

Please or to participate in this conversation.