Making requests for the menu items and options on both the menu and cart pages of the site is unnecessary in sveltekit's SPA structure. Instead, let's make a request for the menu items and options inside the __layout file of routes directory, which will only run once when the user loads either the cart or menu pages. When the user switches between the two, this file won't run.
To get the data from the __layout file into the actual pages (menu and cart), you can either use Svelte's context API or a store. I recommend a store in this case.
Making requests for the menu items and options on both the menu and cart pages of the site is unnecessary in sveltekit's SPA structure. Instead, let's make a request for the menu items and options inside the __layout file of routes directory, which will only run once when the user loads either the cart or menu pages. When the user switches between the two, this file won't run.
To get the data from the __layout file into the actual pages (menu and cart), you can either use Svelte's context API or a store. I recommend a store in this case.