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

Alexsighy's avatar

Inertia Link not working if imported from app.js

Hello, I'm trying to import the Link component in app.js so that I can have it globally,

I've done it pretty simply:

import { Link } from '@inertiajs/vue3'
createInertiaApp({
    ...
    setup({ el, App, props, plugin }) {
      createApp({ render: () => h(App, props) })
        .component('Link', Link)

and I'm summoning it via <Link :href="route('index')">Index</Link>, in inspect element I see that it changes to <a> however... when I click on it, it changes the page by refreshing instead of SPA, I need your help with this :D

I've tried changing it into .component("InertiaLink", Link) and it didn't do anything differently

0 likes
1 reply
Alexsighy's avatar
Alexsighy
OP
Best Answer
Level 1

I've solved it, sadly I was importing inertiajs/vue3 twice with

import { createInertiaApp } from '@inertiajs/inertia-vue3';
import { Link } from '@inertiajs/inertia-vue3';

Fixed it by import { createInertiaApp, Link } from '@inertiajs/inertia-vue3';

Please or to participate in this conversation.