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
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 andthrow 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 -yInstalls 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 7Similar to Sveltekit Data Flow
More Frontend & UI Codesveltekit-remote-functionsSkillspences10/svelte-skills-kit441 installsExperimental SvelteKit guidance for choosing and using query(), form(), command(), and prerender() in .remote.ts files.
svelte-skillsPluginspences10/svelte-skills-kit96 starsSvelte 5 runes, SvelteKit data flow, routing, and structure patterns
sveltekitSkillmindrally/skills773 installsExpert SvelteKit guidance covering routing, SSR/SSG, form actions, and Tailwind styling for TypeScript projects.
nextjs-best-practicesSkilldavila7/claude-code-templates635 installsNext.js App Router principles covering Server Components, data fetching, routing, caching, and server actions.
frontend-react-router-best-practicesSkillsergiodxa/agent-skills406 installsReact Router data-loading, action, and route-organization rules with code examples for performance and architecture.
remixSkillmindrally/skills733 installsExpert Remix guidance covering loaders, actions, nested routes, and server-first full-stack patterns in TypeScript.