Hi,
Livewire (https://livewire.laravel.com) is a popular framework for creating Laravel apps that work like SPAs. Very similar to the way Turbo works for Rails.
Like Turbo, Livewire replaces the entire <body> tag on each navigation, so as soon as you navigate the messenger is destroyed.
Intercom includes support for Turbo by monitoring the “turbo:visit” and “turbo:load” events to unload and reload the messenger on every navigation. Livewire has equivalent events in “livewire:navigate” and “livewire:navigated” (https://livewire.laravel.com/docs/navigate#javascript-hooks).
This request is to add livewire:navigate and livewire:navigated to the list of destroy/recreate events that the Intercom messenger loader observes.
In the meantime I have worked around this issue by adding this to our codebase. It creates fake turbo events that the messenger responds to. This works fine to unload/reload the messenger on every navigation.
document.addEventListener("livewire:navigate", (event) =>
document.dispatchEvent(
new CustomEvent("turbo:visit", {
detail: {
url: event.detail.url.toString(),
action: "advance",
},
}),
),
);
document.addEventListener("livewire:navigated", () => document.dispatchEvent(new CustomEvent("turbo:load", { detail: { url: window.location.href } })));
Thanks!
- Chris