en un clic
reactive-ui-patterns
// Remote functions reactive UI patterns. Use for smooth in-place updates, preventing page jumps, and managing loading states with .current property.
// Remote functions reactive UI patterns. Use for smooth in-place updates, preventing page jumps, and managing loading states with .current property.
| name | reactive-ui-patterns |
| description | Remote functions reactive UI patterns. Use for smooth in-place updates, preventing page jumps, and managing loading states with .current property. |
<script lang="ts">
const data_query = get_data(); // Store in variable for .current access
async function save(id: string, value: string) {
await update_data({ id, value });
await data_query.refresh(); // Updates in place!
}
</script>
{#if data_query.error}
<p>Error loading data</p>
{:else if data_query.loading && data_query.current === undefined}
<p>Loading...</p>
{:else}
{@const items = data_query.current ?? []}
<div class:opacity-60={data_query.loading}>
{#each items as item}<!-- Content updates smoothly -->{/each}
</div>
{/if}
const query = get_data() enables .current
property access.current: Prevents page jumps, keeps scroll position
during updates.current === undefined,
not on every refresh{#await}: Causes jarring page reloads - use stored query
pattern instead.current propertyDatabase migration patterns for SQLite. Use when creating migrations, modifying schema, or running database changes.
SvelteKit patterns for devhub-crm. Use for remote functions (query, form, command), routing, and server-side logic.
Better-auth integration for authentication. Use when implementing login, registration, protected routes, or email verification.
Vitest browser mode component testing. Use for testing Svelte 5 components with real browsers, locators, accessibility patterns, and reactive state.
SQLite operations using better-sqlite3 with prepared statements. Use when implementing CRUD operations, timestamps, and user-scoped queries with row-level security.
Svelte 5 error handling. Use for error boundaries, async await expressions, loading states, and form errors.