Something went wrong. Try again.
Monorepo for Tangled tangled.org
Something went wrong. Try again.
Svelte
12345678910111213141516171819202122232425262728293031323334353637<script lang="ts"> import { browser } from "$app/environment"; import type { Snippet } from "svelte";
interface Props { /** omit to fill in silently, the boundary still owns the suspension */ skeleton?: Snippet; /** without it the error propagates to the nearest +error.svelte */ failed?: Snippet<[error: unknown]>; children: Snippet; }
let { skeleton, failed: failedProp, children }: Props = $props();</script>
<!-- keep the browser check, svelte throws the real children away on ssr if pending is set --><!-- failed has to be a direct child of the boundary to register as its snippet -->{#if failedProp} <svelte:boundary pending={browser ? gated : undefined}> {@render children()} {#snippet failed(error: unknown)} {@render failedProp(error)} {/snippet} </svelte:boundary>{:else} <svelte:boundary pending={browser ? gated : undefined}> {@render children()} </svelte:boundary>{/if}
<!-- no delay here: load.ts already held the navigation for the window -->{#snippet gated()} {#if skeleton} {@render skeleton()} {/if}{/snippet}