sveltekit
Assists with building full-stack web applications using SvelteKit. Use when creating Svelte apps with file-based routing, server-side rendering, form actions, or API endpoints. Trigger words: sveltekit, svelte, svelte routing, form actions, svelte hooks, svelte adapter, svelte load function.
What this skill does
# 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: `+page.svelte` for pages, `+layout.svelte` for shared layouts, `+server.ts` for API endpoints, and route groups `(name)` for shared layouts without URL impact. - When loading data, use `+page.server.ts` for server-only loading (database queries, secrets) and `+page.ts` for universal loading. Keep `load()` functions thin and move business logic to `$lib/server/`. - When handling forms, use server-side form actions in `+page.server.ts` with `fail()` for validation errors and `redirect()` for success. Add `use:enhance` for progressive enhancement. - When creating API routes, export `GET`, `POST`, `PUT`, `DELETE` handlers from `+server.ts` files, returning `json()`, `text()`, or `error()` responses. - When configuring rendering, default to SSR, use `export const prerender = true` for static pages (marketing, docs, blog), and `export const ssr = false` for client-only pages. - When adding middleware, use `src/hooks.server.ts` with the `handle` function for auth, logging, and redirects, and `sequence()` to compose multiple hooks. - When deploying, choose the appropriate adapter: `adapter-auto` for auto-detection, `adapter-node` for self-hosted, `adapter-static` for full SSG, or platform-specific adapters for Vercel, Cloudflare, or Netlify. ## Examples ### Example 1: Build a CRUD app with form actions **User request:** "Create a SvelteKit app with form-based task management" **Actions:** 1. Define routes for task list (`/tasks/+page.svelte`) and detail (`/tasks/[id]/+page.svelte`) 2. Implement `load()` in `+page.server.ts` to fetch tasks from the database 3. Add form actions for create, update, and delete with Zod validation 4. Enhance forms with `use:enhance` for no-JS fallback **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:** 1. Create marketing pages with `export const prerender = true` 2. Build dashboard routes with SSR and `+page.server.ts` for authenticated data loading 3. Add auth hook in `src/hooks.server.ts` to protect dashboard routes 4. Configure `adapter-vercel` with edge functions for the dashboard **Output:** A hybrid app with pre-rendered marketing pages and server-rendered authenticated dashboard. ## Guidelines - Use `+page.server.ts` for data loading that touches databases or secrets; never expose credentials in `+page.ts`. - Default to server-side form handling with actions; add `use:enhance` for progressive enhancement. - Use `export const prerender = true` on marketing pages, docs, and blog posts. - Keep `load()` functions thin: fetch data and return it, move business logic to `$lib/server/`. - Use route groups `(name)` to share layouts without affecting URLs. - Set `data-sveltekit-preload-data="hover"` on links for perceived-instant navigation. - Always handle the `form` prop in `+page.svelte` to display validation errors after failed actions.
Related in Web Dev
generating-lwc-components
IncludedLightning Web Components with PICKLES methodology and 165-point scoring. Use this skill when the user creates or edits LWC components, builds wire service patterns, or writes Jest tests for LWC. TRIGGER when: user creates/edits LWC components, touches lwc/**/*.js, .html, .css, .js-meta.xml files, or asks about wire service, SLDS, or Jest LWC tests. DO NOT TRIGGER when: Apex classes (use generating-apex), Aura components, or Visualforce.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Set up queries with useQuery, mutations with useMutation, configure QueryClient caching strategies, implement optimistic updates, and handle infinite scroll with useInfiniteQuery. Use when: setting up data fetching in React projects, migrating from v4 to v5, or fixing object syntax required errors, query callbacks removed issues, cacheTime renamed to gcTime, isPending vs isLoading confusion, keepPreviousData removed problems.
document-processor-api
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
nutrient-document-processing
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Covers useMutationState, simplified optimistic updates, throwOnError, network mode (offline/PWA), and infiniteQueryOptions. Use when setting up data fetching, fixing v4→v5 migration errors (object syntax, gcTime, isPending, keepPreviousData), or debugging SSR/hydration issues with streaming server components.
accelint-nextjs-best-practices
IncludedNext.js performance optimization and best practices. Use when writing Next.js code (App Router or Pages Router); implementing Server Components, Server Actions, or API routes; optimizing RSC serialization, data fetching, or server-side rendering; reviewing Next.js code for performance issues; fixing authentication in Server Actions; or implementing Suspense boundaries, parallel data fetching, or request deduplication.