SPA Routing Issue

Hello!

I’m currently building my first SPA on bubble. I’m having a bit of an issue when it comes to routing.

Say a user “navigates” to the /timetable “page”. I load that section of the page and update the url to https://website.com/timetable

Since it’s an SPA, the user never actually leaves the page, however, if the user reloads the page (or I update the app forcing a reload), they are brought to the 404 page.

Is there a way to solve this problem? Does bubble have a SPA toggle to let it konw that it’s a single page app?

1 Like

On my SPA I have a ‘when page is loaded’ workflow on the index page:

this way whenever the page loads the ‘home’ page will always show.

2 Likes

Hey! The issue happens because Bubble doesn’t natively treat SPA URLs like typical frameworks. To fix this, use URL parameters like ?tab=timetable instead of paths, so Bubble knows where to load on refresh. Alternatively, plugins like Pathfinder can help manage paths for SPA

URL parameters are a great way to handle SPA navigation.

Not sure if I would use a plugin for this purpose… actually no, I would not use a plugin for this purpose. Why add a dependency when it can be avoided?

I’m old fashioned and like to keep things simple so they simply work.

Darn, was hoping to not have to use parameters so it looked cleaner. Oh well! Parameters it is!

Id have to see how you have them being navigated or how the url is created. Because my spa works great when reloaded or refreshed.

This topic was automatically closed after 70 days. New replies are no longer allowed.