sveltekit

Build full-stack SvelteKit applications with file-based routing, SSR, API routes, and form actions.

1|Updated Dec 29, 2025
One-click install
npx skills add https://github.com/ratnesh-maurya/tracker.ratnesh-maurya.com --skill sveltekit-ratnesh-maurya
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: sveltekit
Source: https://github.com/ratnesh-maurya/tracker.ratnesh-maurya.com/tree/main/.claude/skills/sveltekit
Command: npx skills add https://github.com/ratnesh-maurya/tracker.ratnesh-maurya.com --skill sveltekit-ratnesh-maurya

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building a full-stack web app often requires stitching together separate frontend and backend frameworks. This Skill guides you through SvelteKit's unified model so you can handle routing, server rendering, data loading, and mutations in one codebase without configuration overhead. ## Core Features & Use Cases - File-Based Routing: Map +page.svelte files directly to URLs, including dynamic segments, catch-all routes, and route groups. - Server-Side Data Loading: Use +page.server.ts load functions and hooks to fetch data and manage sessions securely on the server. - API Routes & Form Actions: Create REST endpoints with +server.ts and handle mutations with progressive-enhancement form actions that work without JavaScript. - Use Case: You need a blog with SSR for SEO, a protected dashboard, and a contact form. This Skill walks you through scaffolding, dynamic [slug] routes, auth via hooks.server.ts, and a form action with validation and redirect. ## Quick Start Ask the AI to scaffold a new SvelteKit app with TypeScript and create a blog route that loads posts from a server-side load function.

Frequently Asked Questions about sveltekit

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a full-stack app with SvelteKit?▼

Run npm create svelte@latest, choose the Skeleton project with TypeScript, then define pages as +page.svelte files under src/routes. Add +page.server.ts for server data loading and +server.ts files for API endpoints.

How do SvelteKit form actions work?▼

Form actions are defined in +page.server.ts as an exported actions object that receives formData from POST submissions. Use fail() for validation errors and redirect(303) after success, and apply use:enhance on the form for progressive enhancement.

What is the difference between +page.ts and +page.server.ts in SvelteKit?▼

+page.ts is a universal load function that runs on both server and client, while +page.server.ts runs only on the server. Use the server variant for database queries, secrets, and auth logic since it never ships to the browser.

Does SvelteKit support SSR and static site generation per route?▼

Yes, SvelteKit controls rendering per route with page options. Set prerender = true for static generation at build time, ssr = true for server rendering per request, and csr = false to disable client-side hydration.

Why is locals.user undefined in my SvelteKit load function?▼

The locals object is only populated if you set it in src/hooks.server.ts before calling resolve(). Add a handle function that reads the session cookie, verifies the token, and assigns the result to event.locals.user.

When should I not use SvelteKit form actions?▼

Form actions are tied to page routes, so they do not fit APIs consumed by external clients or mobile apps. For those cases, create standalone +server.ts endpoints that accept and return JSON instead.