-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Firefox & Safari loses store navigating because they does NOT support Navigation API yet #688
Comments
@AlbertSabate maybe as a workaround we can use something like this: const storage = sessionStorage.getItem('s');
if(storage) $window._S = [...($window._S ?? []), ...JSON.parse(storage)]
$window.addEventListener('beforeunload', (event) => sessionStorage.setItem('s', JSON.stringify(Array.from($window._s.Map.entries())))) here: brisa/packages/brisa/src/utils/signals/index.ts Lines 27 to 29 in 0228664
|
Sounds like a nice workaround to have. For me there are couple of things to consider:
|
Probably we can use some flag like |
However, this approach only addresses the issue of the store being consumed directly by the client. However, it does not resolve these following scenarios:
It only resolves these cases:
The limitation is that the store is not stored in a cookie or any other mechanism accessible from the server. This means the server cannot retrieve the updated store when rendering the new page, leaving the state disconnected between client and server. |
This task remains pending for the time being. I lower its priority. Before we do anything messy like involving storage, cookies, or params to fix this, let's wait for Safari issue and Firefox issue to support the Navigation API. We will only take up this issue in case we see that it is very demanded by the Brisa community. For now, there is this polyfill for the Navigation API https://github.com/virtualstate/navigation ( |
as a recommendation: to share a state between pages, use the parameters when navigating. It also makes no sense for a page to be different when navigating than when rendering from scratch. When Safari and Firefox support the Navigation API, you will be able to use the store between pages as it works right now with Chrome / Edge. |
Firefox & Safari loses store navigating because they does NOT support Navigation API yet.
Maybe we need a temporal alternative like use the sessionStorage for the store to then recover? 🤔 We need to investigate it.
CC: @AlbertSabate
The text was updated successfully, but these errors were encountered: