Skip to content
spences10 avatar

Sveltekit Data Flow

Quick-reference guide for SvelteKit load functions, form actions, serialization, and invalidation choices.

CCM score
56 of 100
skills.sh installs
534
GitHub stars
96
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers server versus universal load functions, with a decision rule for choosing between +page.server.ts, +page.ts, and +server.ts
  • Includes a form-actions example that returns fail() for validation errors and throw redirect() on success
  • Enforces that load data be JSON-serializable, with no class instances or functions passed from server load
  • Designed for developers building SvelteKit routes who need reference patterns for data flow and invalidateAll()

Install

$ npx -y skills add spences10/svelte-skills-kit --skill sveltekit-data-flow -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

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

Details

Repository
github.com/spences10/svelte-skills-kit
Categories
Frontend & UI Code, Backend & APIs
First seen
Jun 3, 2026

Questions

What does the sveltekit-data-flow skill cover?

sveltekit-data-flow gives guidance on SvelteKit load functions, form actions, server and client data, and invalidation. It explains when to use +page.server.ts versus +page.ts, what data can be serialized, and how to use fail(), redirect(), error() and invalidateAll().

Which file should I use for server-only data in sveltekit-data-flow?

The sveltekit-data-flow skill says to use +page.server.ts for server-only work such as database access and secrets. Use +page.ts for universal load functions that run on both server and client, and +server.ts for API routes.

How do I install the sveltekit-data-flow skill?

Run npx -y skills add spences10/svelte-skills-kit --skill sveltekit-data-flow -y in a project to install it. Once installed, the skill lets the agent answer SvelteKit data flow questions with guidance on load functions and form actions.

Which skills in the same category does sveltekit-data-flow sit alongside?

sveltekit-data-flow sits in the Frontend & UI Code category, next to vercel-react-best-practices, web-design-guidelines and design-taste-frontend. Its focus is narrower, covering SvelteKit server and client data handling rather than general frontend design.

More from spences10/svelte-skills-kit

All 7

Similar to Sveltekit Data Flow

More Frontend & UI Code