Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pushing a URL with router without making a request is broken #2211

Open
gvlasov opened this issue Jan 25, 2025 · 1 comment
Open

Pushing a URL with router without making a request is broken #2211

gvlasov opened this issue Jan 25, 2025 · 1 comment

Comments

@gvlasov
Copy link

gvlasov commented Jan 25, 2025

Version:

  • @inertiajs/core version: 2.0.3
  • @inertiajs/vue3 version: 2.0.3

Describe the problem:

Docs promise that there is a router.push() method to update current URL in browser without making an Inertia request, but accessing that method results in:

chunk-U3LI7FBV.js?v=c55547f8:2332 Uncaught TypeError: router.push is not a function
    at Proxy.setCollectionRoute (Collections.vue:44:12)
    at onClick (Collections.vue:67:29)
    at chunk-U3LI7FBV.js?v=c55547f8:11231:45
    at callWithErrorHandling (chunk-U3LI7FBV.js?v=c55547f8:2263:19)
    at callWithAsyncErrorHandling (chunk-U3LI7FBV.js?v=c55547f8:2270:17)
    at callWithAsyncErrorHandling (chunk-U3LI7FBV.js?v=c55547f8:2281:19)
    at HTMLButtonElement.invoker (chunk-U3LI7FBV.js?v=c55547f8:11202:5)

While other methods, e.g. visit(), work on the router object, so this is not a configuration issue.

Steps to reproduce:

In a Vue3 typescript SFC:

<script lang="ts" setup>
    import {router} from '@inertiajs/vue3'
    function push() {
      router.push('/something')
    }
    
</script>
<template>
  <button @click="push"/>
</template>
@gvlasov gvlasov changed the title Pushing a URL without making a request is broken Pushing a URL with router without making a request is broken Jan 25, 2025
@Verox001
Copy link

Verox001 commented Feb 1, 2025

Thanks for the report! I extensively tested this with Vue 3, React, and Svelte but was unable to reproduce the issue.

Please ensure that you're importing the router only from @inertiajs/vue3 and check your package.json for any duplicate @inertia/* package installations.

It sounded like you might have both @inertiajs/core and @inertiajs/vue3 installed, which shouldn't be necessary since @inertiajs/vue3 already depends on @inertiajs/core. If both are present, try uninstalling @inertiajs/core, as using both could be causing the issue.

If that doesn’t resolve it, try deleting your node_modules directory and reinstalling all dependencies, as this often fixes corrupted package installations.

Let me know if you discover anything new!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants