An issue with loading JS when linking to the dashboard
For some reason, the JavaScript on the page doesn't load properly when navigating to the dashboard, as shown in the video, although it works fine upon refreshing.
I just tested it on a freshly installed Laravel/Filament app, with
npm run build
+ npm run dev
Laravel Version ..... 11.19.0
Filament ..... v3.2.97
Livewire ..... v3.5.4
Video in comments 👇Solution:Jump to solution
Yeah. So nothing we can do about it. Not sure whether it's a "bug" or just not considered an option for SPA mode. I mean it's not really an SPA at that point anymore.
18 Replies
Do you use
->spa()
mode?
Also: Please don't post videos with background music 😅 Just listened to the weirdest remix everNo,
spa()
is not enabled in filament, although the link adminitration
has wire:navigate
on it.
*Sorry about the music, I thought it wasn't recorded lol, I'll reupload an edited version *you have lots of issues there run:
npm run build
How are you also serving the application?
I think the issues are related to the same problem (not loading js files)
I ran npm run build and also npm run dev for a second test, and the issues went away after refreshing or typing the link directly
I just use
php artisan serve
and is the .env app_url the same as what you are access the app over? I suspect not.
Yes it is the same.
I think this is a very specific issue where it only happens when navigating to the admin panel by clicking a link that has `wire:navigate'
Not sure if it's worth investigating but if so, I can create a reproduction repo
Look at your network logs for why they are failing, it'll be url issue
I recommend herd for localised dev.
No, weirdly everything is loaded correctly
I use valet usually & I just can't do the switch atm
valet is a smaller version of herd. So fine, should need to run php artisan serve then.
Provide more indepth reporting of the rrors.
Looks like jetstream is using spa mode. That's why you are seeing the wire:navigate on the link. The problem with that is that wire:navigate doesn't reload the page, as a side effect all of filament's js and css assets don't get loaded on the page.
i'm surprised the errors are for livewire.js though. can you share the console errors in a screenshot?
Sure
I think this is the right explanation, although, is this an expected issue?
So if you remove this, does it work?
Yes, when the page gets reloaded due to a normal link naviagation it works
i'm surprised the errors are for livewire.js though. can you share the console errors in a screenshot?JS is not loaded, Alpine tries to run JS code from a file that was not loaded.
Solution
Yeah. So nothing we can do about it. Not sure whether it's a "bug" or just not considered an option for SPA mode. I mean it's not really an SPA at that point anymore.
I know it's not even a big problem,
I noticed this issue when I tried to set up Filament with NativePHP and I wanted to raise attention in case it's an actual problem.
Anyway, thank you all for you help and time 🙏