I have a sveltekit app. in one page -cart.svelte- I press a button to go to page where I choose if the order for pickup or delivery -ordertype.svelte- but I lost the cart content because it is a svelte store. I'm trying to use pushState() to navigate to order type page without triggering a reload - so I can keep the cart store - and according to the docs, the pushState is the right tool for that. When I click the button, it will navigate to the ordertype page but the $page.state.cart is an empty object. How do I cause the navigation without running reload? ShallowRouting that was introduced in kit 2.0
..Order Now Path to ordertype without reloadand the gotoordertype function code is where I TRY pushState async function gotoordertype(){
sessionStorage.setItem("cart", JSON.stringify(cart.checkout()) )
pushState('/ordertype', {
cart: JSON.stringify(cart.checkout())
})
//goto('/ordertype')
}
I tested a link with data-sveltekit-replacestate and it does work. It navigate without losing the cart content, I navigate to ordertype and cart contents still there in the memory BUT I need to run a form action too that belong to ordertype page. So is not possible for me. I need a button where I can point to the right formactions but now I can't use the wonderful data-sveltekit-replacestate??
How do I persist cart in memory and prevent rerunning the load function after navigation to the ordertype page? How do you pass the cart content from page one to page two, is it something I need to explicitly write like $page.state.cart and get that in ordertype.svelte. How do I do that?