inertiajs / inertia

Inertia.js lets you quickly build modern single-page React, Vue and Svelte apps using classic server-side routing and controllers.
https://inertiajs.com
MIT License
6.54k stars 432 forks source link

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

Open ariel-codes opened 4 months ago

ariel-codes commented 4 months ago

Versions:

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:

pedroborges commented 2 months ago

@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.