Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fetch initial values for session in svelte/sapper

Tags:

svelte

sapper

I am using svelte/sapper with polka. I have some initial values to be fetched and stored in session from a web service before any page is loaded. What is the best recommended way to do this.

I tried doing this in _layout in the root. But as the fetch is asynchronous, values are not available in the first page load.

like image 626
Anil Sivadas Avatar asked Jan 26 '23 04:01

Anil Sivadas


1 Answers

Your layout components can use preload: https://sapper.svelte.dev/docs#Preloading

like image 55
Rich Harris Avatar answered Mar 24 '23 12:03

Rich Harris