sveltekit-data-flow

SvelteKit data flow guide. Covers load functions, form actions, server- and client-side data, and invalidation mechanisms. Explains the differences between +page.server.ts and +page.ts, serialization considerations, and usage of fail(), redirect(), error(), and invalidateAll().

Last repository push
GitHub Stars
96
Forks
3
Issues / PRs
2

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "sveltekit-data-flow" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-a63aebbf26793f140990f11fd102748865ed7bb633bfcc5f4b656026e65b7a45. Verify the upstream source and version against https://github.com/spences10/svelte-skills-kit before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

SvelteKit data flow guide. Covers load functions, form actions, server- and client-side data, and invalidation mechanisms. Explains the differences between +page.server.ts and +page.ts, serialization considerations, and usage of fail(), redirect(), error(), and invalidateAll().

0 Downloads

Introduction source: third_party · spences10 · 0.0.1 Reference

SkillPi interpretation

Tasks
SvelteKit data flow guidance. Use for load functions, form actions, server/client data, and invalidation. Covers +page.server.ts vs +page.ts, serialization, fail(), redirect(), error(), invalidateAll().
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: sveltekit-data-flow
# IMPORTANT: Keep description on ONE line for agent compatibility
# prettier-ignore
description: "SvelteKit data flow guidance. Use for load functions, form actions, server/client data, and invalidation. Covers +page.server.ts vs +page.ts, serialization, fail(), redirect(), error(), invalidateAll()."

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

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

<!-- PROGRESSIVE DISCLOSURE GUIDELINES:

  • Keep this file ~50 lines total (max ~150 lines)
  • Use 1-2 code blocks only (recommend 1)
  • Keep description <200 chars for Level 1 efficiency
  • Move detailed docs to references/ for Level 3 loading
  • This is Level 2 - quick reference ONLY, not a manual

LLM WORKFLOW (when editing this file):

  1. Write/edit SKILL.md
  2. Format (if formatter available)
  3. Run: npx skills add . --list
  4. If the skill is not discovered, check SKILL.md frontmatter formatting
  5. Validate again to confirm -->

Current listing version

0.0.1

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value75/100

Highlights

  • SvelteKit 数据流指南覆盖 load 函数、表单操作、服务端/客户端数据及失效机制等核心开发场景
  • 提供 +page.server.ts 与 +page.ts 的区别、序列化、fail()/redirect()/error()/invalidateAll() 等实用方法详解
Trigger Precision95/100

Highlights

  • description 精准描述 Skill 用途和覆盖范围,触发词完整且边界清晰
Structure and Standards90/100

Highlights

  • 结构清晰,包含 Quick Start、Example、Reference Files、Notes 等部分
  • frontmatter 完整,代码示例恰当,符合文档规范
Execution Reliability60/100

Areas to improve

  • Missing referenced files Reported severity: Major

    SKILL.md 中引用了 references/ 目录下的多个文件(如 load-functions.md、form-actions.md 等),但当前传入内容未包含这些文件

    Recommendation: 请补充 references/ 目录下的所有引用文件,确保用户能获取完整信息

Evidence Verifiability (mean of the first four)80/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

  • Install or fetch external dependencies

    Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.

    Mentioned in main document · lines 76

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.