Components
Live data
Things that change while people watch should change in front of them. The database says which round changed over a WebSocket (Supabase Realtime); the page re-reads its own data through the server, which keeps every rule. Numbers count up, a pulsing dot says it is live, and slow parts stream in behind skeletons.
A live board
Top supporters so far
Live
- 1 Maryam K. 0 toman
- 2 Arash 0 toman
- 3 Niloufar R. 0 toman
- 4 Kaveh 0 toman
Example names and amounts; a new gift arrives every few seconds.
Streaming in
The Skeleton shows the first time only: Load Again keeps what is there until the next answer comes, as a live change does.
Rules
- Live where people watch numbers change: the home page hero, the episode page, campaigns, My activity.
- The socket only says which round changed, never who or how much; the page re-reads through the server.
- A slow poll stays on as a safety net, and the page re-reads when its tab comes back into view.
- Show “Live” with a pulsing turquoise dot only while the socket is connected.
- Numbers count up; a row that just changed glows copper for a moment. Respect reduced motion.
- Slow data streams in behind skeletons: the page never waits for its slowest part.
- Read again, a part keeps its last answer on screen until the next one comes; the Skeleton is for the first time only, and a view a person moved (a canvas) stays where they left it.
Code
<script lang="ts">
import LiveUpdates from '#lib/components/LiveUpdates.svelte';
import { Status } from '#lib/components/ui/status/index.js';
let { data } = $props();
let live = $state(false);
</script>
<!-- The server returns { url, key, topics: ['experience-12'] } for the rounds that can change. -->
<LiveUpdates realtime={data.realtime} bind:connected={live} />
{#if live}<Status tone="success" live>Live</Status>{/if}