sveltekit-data-flow

Which file? Server-only (DB/secrets): +page.server.ts | Universal (runs both): +page.ts | API: +server.ts

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "sveltekit-data-flow" with this command: npx skills add spences10/svelte-skills-kit/spences10-svelte-skills-kit-sveltekit-data-flow

SvelteKit Data Flow

Quick Start

Which file? Server-only (DB/secrets): +page.server.ts | Universal (runs both): +page.ts | API: +server.ts

Load decision: Need server resources? → server load | Need client APIs? → universal load

Form actions: Always +page.server.ts . Return fail() for errors, throw redirect() to navigate, throw error() for failures.

Example

// +page.server.ts import { fail, redirect } from '@sveltejs/kit';

export const load = async ({ locals }) => { const user = await db.users.get(locals.userId); return { user }; // Must be JSON-serializable };

export const actions = { default: async ({ request }) => { const data = await request.formData(); const email = data.get('email');

	if (!email) return fail(400, { email, missing: true });

	await updateEmail(email);
	throw redirect(303, '/success');
},

};

Reference Files

  • load-functions.md - Server vs universal

  • form-actions.md - Form handling patterns

  • serialization.md - What can/can't serialize

  • error-redirect-handling.md - fail/redirect/error

  • client-auth-invalidation.md - invalidateAll() after client-side auth

Notes

  • Server load → universal load via data param | ALWAYS throw redirect()/error()

  • No class instances/functions from server load (not serializable)

  • Last verified: 2025-01-11

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

sveltekit-structure

No summary provided by upstream source.

Repository SourceNeeds Review
General

svelte-runes

No summary provided by upstream source.

Repository SourceNeeds Review
General

sveltekit-remote-functions

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

Agent Memory System v8

生产级 Agent 记忆系统 — 6维坐标编码 + RRF双路检索 + sqlite-vec统一存储 + 写入时因果检测 + 多Agent共享 + 记忆蒸馏 + 时间旅行 + 情感编码 + 元认知 + 内在动机 + 叙事自我 + 数字孪生 + 角色模板

Registry SourceRecently Updated