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

Router only checks that window.history.state isn't empty, breaks when used with other frameworks #1915

Open
ariel-codes opened this issue Jul 11, 2024 · 1 comment

Comments

@ariel-codes
Copy link

Versions:

  • @inertiajs/core version: 1.2.0
  • @inertiajs/vue2 version: #.#.#
  • @inertiajs/vue3 version: #.#.#
  • @inertiajs/react version: 1.2.0
  • @inertiajs/svelte version: #.#.#

Describe the problem:

When navigating back/forward from pages, the router only checks that window.history.state is not empty, but this can conflict with other navigation frameworks (in my case Turbo/Hotwire, which uses window.history.state.turbo). This in turn leads to the resolve function passed to createInertiaApp being called with an undefined arg.

Steps to reproduce:

  • Set window.history.state to any truthy value before initializing Inertia
@ariel-codes ariel-codes changed the title Router only checks that window.history.state is _not empty_, breaks when used with other frameworks Router only checks that window.history.state isn't empty, breaks when used with other frameworks Jul 11, 2024
@pedroborges
Copy link
Collaborator

@ariel-codes I'm curious about how you're integrating Inertia.js with Turbo/Hotwire, as they generally aim to solve similar problems but in different ways. It's my understanding that Turbo drives navigation and partial updates without the need for a front-end framework, while Inertia integrates tightly with frameworks like Vue, React, and Svelte.

Since both manipulate the history.state, it's understandable that there would be conflicts in scenarios where both are being used. As for Inertia, we might need a safeguard to confirm the presence of Inertia-specific data in history.state before continuing execution.

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