Skip to content

bug: Vue: Incorrect href [object Object] when using router-link object #30848

Closed

Description

@comandos

Prerequisites

Ionic Framework Version

v8.x

Current Behavior

When using the router-link attribute on Ionic Vue components (e.g. <ion-button>, <ion-item>), and passing a Vue Router location object such as:

<ion-button :router-link="{ name: 'details' }">Details</ion-button>

the component navigates correctly, but the generated DOM contains incorrect href values.

Both the host element and the internal Shadow DOM anchor render [object Object] instead of the resolved URL.

Example rendered output:

<ion-button routerlink="[object Object]">
  <template shadowrootmode="open">
    <a href="[object Object]" class="button-native">
      <span class="button-inner">...</span>
    </a>
  </template>
  Details
</ion-button>

This results in:

  • Browser status bar showing [object Object] on hover
  • Incorrect link preview for assistive technologies
  • No way to know the actual target URL from DOM
  • Real href never being exposed, navigation works only via JS event interception

Expected Behavior

Ionic should resolve { name: 'details' } into the actual route URL (e.g. /details) and reflect it either:

  • on the host element (routerlink="/details")
  • or on the internal <a> element inside Shadow DOM (href="/details")

So that:

  • browser hover shows the correct URL
  • accessibility tools detect the correct destination
  • the link behaves like a normal anchor
  • DOM correctly represents the navigation target

Steps to Reproduce

  1. Create an Ionic Vue project.
  2. Add a component using router-link with an object:
<ion-button :router-link="{ name: 'details' }">
  Details
</ion-button>
  1. Hover over the component.
  2. Inspect the DOM.

Result: both the routerlink attribute and the internal <a href> contain [object Object]

Code Reproduction URL

https://v6ckjp.csb.app/

Ionic Info

Ionic:

   Ionic CLI       : 7.2.1
   Ionic Framework : @ionic/vue 8.7.11

Capacitor:

   Capacitor CLI      : 7.4.4
   @capacitor/android : 7.4.4
   @capacitor/core    : 7.4.4
   @capacitor/ios     : 7.4.4

Utility:

   cordova-res : not installed globally
   native-run  : 2.0.1

System:

   NodeJS : v22.13.1
   npm    : 10.9.2
   OS     : Linux 6.8

Additional Information

No response

Activity

  1. Mudavath-kumar commented on Dec 22, 2025

    @Mudavath-kumar

    Hi! I’d like to work on this issue.

    I’ve reviewed the report and reproduced the [object Object] behavior when passing a Vue Router location object (e.g. { name: "details" }) into router-link on components like ion-button and ion-item. Navigation works correctly, but the rendered DOM does not reflect the resolved URL in either the routerlink attribute or the internal anchor href.

    My plan is to:

    Inspect how routerLink values are handled inside the Ionic Vue wrapper

    Resolve router location objects into actual href strings (e.g. using router.resolve())

    Ensure both the host attribute and internal anchor reflect the correct path

    Test with named routes, params, and string paths to confirm consistent output

    Open a PR once the correct DOM output is verified

    Before I begin, I have one quick question:
    – Should the resolution logic be applied at the wrapper level for Vue components, or should the internal anchor generator handle object → string conversion?

    If this direction looks good, please assign this issue to me. Thanks! 🚀

  2. thetaPC commented on Oct 19, 2026

    @thetaPC
    Contributor

    Thanks for the report, and sorry for the delay.

    Verified on 9.0.8. When router-link is given a route location object, @ionic/vue uses the object for navigation, which is why clicking works. It also copies the same object straight into the inner anchor's href without asking Vue Router to resolve it, so the anchor ends up with the text [object Object]. Besides the hover URL, this means ctrl/cmd-clicking to open the link in a new tab loads /[object Object].

    Workaround, verified on 9.0.8 with createWebHistory(): resolve the location yourself and pass the resulting string.

    <template>
      <ion-button :router-link="router.resolve({ name: 'details' }).href">Details</ion-button>
    </template>
    
    <script setup lang="ts">
    import { IonButton } from '@ionic/vue';
    import { useRouter } from 'vue-router';
    
    const router = useRouter();
    </script>

    Tracked as a bug in stenciljs/output-targets.

  3. ShaneK commented on Oct 28, 2026

    @ShaneK
    Member

    Thanks for your report! This has been fixed in v9.0.10!

  4. added a commit that references this issue on Oct 28, 2026
    d73cacb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions