Skills sveltekit
install
source · Clone the upstream repo
git clone https://github.com/TerminalSkills/skills
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/TerminalSkills/skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/sveltekit" ~/.claude/skills/terminalskills-skills-sveltekit && rm -rf "$T"
manifest:
skills/sveltekit/SKILL.mdsource content
SvelteKit
Overview
SvelteKit is a full-stack framework built on Svelte's compiler-first approach, shipping minimal JavaScript with no virtual DOM runtime. It provides file-based routing for pages and API endpoints, server-side form actions with progressive enhancement, and deployment adapters for any hosting platform.
Instructions
- When setting up routing, use file-based conventions:
for pages,+page.svelte
for shared layouts,+layout.svelte
for API endpoints, and route groups+server.ts
for shared layouts without URL impact.(name) - When loading data, use
for server-only loading (database queries, secrets) and+page.server.ts
for universal loading. Keep+page.ts
functions thin and move business logic toload()
.$lib/server/ - When handling forms, use server-side form actions in
with+page.server.ts
for validation errors andfail()
for success. Addredirect()
for progressive enhancement.use:enhance - When creating API routes, export
,GET
,POST
,PUT
handlers fromDELETE
files, returning+server.ts
,json()
, ortext()
responses.error() - When configuring rendering, default to SSR, use
for static pages (marketing, docs, blog), andexport const prerender = true
for client-only pages.export const ssr = false - When adding middleware, use
with thesrc/hooks.server.ts
function for auth, logging, and redirects, andhandle
to compose multiple hooks.sequence() - When deploying, choose the appropriate adapter:
for auto-detection,adapter-auto
for self-hosted,adapter-node
for full SSG, or platform-specific adapters for Vercel, Cloudflare, or Netlify.adapter-static
Examples
Example 1: Build a CRUD app with form actions
User request: "Create a SvelteKit app with form-based task management"
Actions:
- Define routes for task list (
) and detail (/tasks/+page.svelte
)/tasks/[id]/+page.svelte - Implement
inload()
to fetch tasks from the database+page.server.ts - Add form actions for create, update, and delete with Zod validation
- Enhance forms with
for no-JS fallbackuse:enhance
Output: A full-stack task management app with progressive enhancement and server-side validation.
Example 2: Deploy a hybrid SvelteKit app
User request: "Set up a SvelteKit site with static marketing pages and dynamic dashboard"
Actions:
- Create marketing pages with
export const prerender = true - Build dashboard routes with SSR and
for authenticated data loading+page.server.ts - Add auth hook in
to protect dashboard routessrc/hooks.server.ts - Configure
with edge functions for the dashboardadapter-vercel
Output: A hybrid app with pre-rendered marketing pages and server-rendered authenticated dashboard.
Guidelines
- Use
for data loading that touches databases or secrets; never expose credentials in+page.server.ts
.+page.ts - Default to server-side form handling with actions; add
for progressive enhancement.use:enhance - Use
on marketing pages, docs, and blog posts.export const prerender = true - Keep
functions thin: fetch data and return it, move business logic toload()
.$lib/server/ - Use route groups
to share layouts without affecting URLs.(name) - Set
on links for perceived-instant navigation.data-sveltekit-preload-data="hover" - Always handle the
prop inform
to display validation errors after failed actions.+page.svelte