Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

Creating a writable svelte store from loaded page data in sveltekit

$
0
0

Using sveltekit with svelte 4,There's data required to server side render pages that is loaded in the root +layout.server.js. The data is then used both on the client and server side, however, I need a way to edit the data after the page is loaded and the $page store is readonly. If I import a store and .set() it inside the root +layout.svelte, then all users/requests will trigger updates to the store on the server side, which is bad.

So how do I go about creating a store, or simple object, that is instantiated in the root server layout, which can be edited on the client side later?

I tried to use depends('data:rates') but that makes all the nested routes rerun their load functions and it still doesn't let me have fine-grained control on the data and timing from the client.

Note that a store limited to one file would work, but this store/object needs to be imported by dozens of locations across the site.

Thanks.


Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>