79108391

Date: 2024-10-21 02:32:43
Score: 1
Natty:
Report link

You can try using isDataRequest from the PageServerLoad arguments.

export const load: PageServerLoad = async ({ isDataRequest, params }) => {
    const data = get(params.id);

    return {
        data: isDataRequest ? data : await data,
    };
}

Link do docs about streaming promises:
https://kit.svelte.dev/docs/load#streaming-with-promises

Then you use the async block to display the skeleton.

Note: it might not work in dev mode, so build the site first.


You can see more info about this method in this article:
https://geoffrich.net/posts/conditionally-stream-data/\ (Keep in mind that you don't need to nest the promise object, SvelteKit 1.x behavior)

Reasons:
  • Blacklisted phrase (1): this article
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Letrix