SvelteKit
Overview
SvelteKit is the official application framework for Svelte (maintained by sveltejs), with the tagline "Web development, streamlined." It provides file-system routing, server-side rendering, data-loading and form-action conventions, and deployment adapters, built on top of Vite. Read this when scaffolding a SvelteKit app or reasoning about routing, load functions, or deployment targets.
Official sources
Install / setup
npx sv create my-app
Core concepts
- File-system routing. Routes live under
src/routes; +page.svelte, +layout.svelte, +page.server.ts, and +server.ts files define pages, layouts, server logic, and endpoints by convention.
- Load functions.
load functions (in +page.js/+page.server.js and layout equivalents) fetch data for a route; server load runs only on the server.
- Form actions. Server
actions handle form submissions with progressive enhancement.
- Rendering modes. Routes can be server-rendered, prerendered (SSG), or run as an SPA, configurable per route.
- Adapters. Deployment adapters target platforms such as Node, static hosting, Cloudflare, Netlify, and Vercel.
- Built on Vite. The dev server and build pipeline use Vite, giving fast HMR and the Vite plugin ecosystem.
Best practices
- Use the official
sv create scaffolder to start a project, then npm run dev — this is the path the docs recommend.
- Put server-only/data-fetching logic in
load functions (server variants for secrets/DB access) rather than in components.
- Use form actions with
<form> for mutations to get progressive enhancement instead of hand-written client fetches.
- Choose the adapter that matches your deployment target so the build output fits the platform.
Common pitfalls
- Importing server-only code (secrets, DB clients) into universal modules → keep it in
*.server.* files / server load so it never ships to the client.
- Expecting browser APIs to exist during SSR → guard with the
browser check from $app/environment or run them in lifecycle hooks.
- Forgetting to install/configure an adapter for your host → add the matching deployment adapter before building for production.
Examples
<!-- src/routes/+page.svelte -->
<script>
export let data;
</script>
<h1>{data.message}</h1>
// src/routes/+page.server.js
export function load() {
return { message: 'Hello from the server' };
}
Further reading
Related skills
- ../nuxt — Vue meta-framework with a comparable model
- ../astro — content-focused framework that also supports Svelte islands
- ../vite — the build tool SvelteKit is built on
1---2name: sveltekit3description: Svelte meta-framework — file routing, SSR/SSG/SPA, load functions, form actions, deploy adapters; consult when building or debugging a SvelteKit app.4domain: stack5category: meta6tags: [svelte, ssr, file-routing, adapters, vite]7official_sources:8 - https://svelte.dev/docs/kit9 - https://github.com/sveltejs/kit10verified: 2026-06-1611metadata:12 source: https://skillmd.com/skills/gabriel7silva/sveltekit13---1415# SvelteKit1617## Overview18SvelteKit is the official application framework for Svelte (maintained by sveltejs), with the tagline "Web development, streamlined." It provides file-system routing, server-side rendering, data-loading and form-action conventions, and deployment adapters, built on top of Vite. Read this when scaffolding a SvelteKit app or reasoning about routing, load functions, or deployment targets.1920## Official sources21- Docs: https://svelte.dev/docs/kit22- Repo: https://github.com/sveltejs/kit23- Install / create a project: https://svelte.dev/docs/kit/creating-a-project2425## Install / setup26```bash27npx sv create my-app28```2930## Core concepts31- **File-system routing.** Routes live under `src/routes`; `+page.svelte`, `+layout.svelte`, `+page.server.ts`, and `+server.ts` files define pages, layouts, server logic, and endpoints by convention.32- **Load functions.** `load` functions (in `+page.js`/`+page.server.js` and layout equivalents) fetch data for a route; server `load` runs only on the server.33- **Form actions.** Server `actions` handle form submissions with progressive enhancement.34- **Rendering modes.** Routes can be server-rendered, prerendered (SSG), or run as an SPA, configurable per route.35- **Adapters.** Deployment adapters target platforms such as Node, static hosting, Cloudflare, Netlify, and Vercel.36- **Built on Vite.** The dev server and build pipeline use Vite, giving fast HMR and the Vite plugin ecosystem.3738## Best practices39- Use the official **`sv create`** scaffolder to start a project, then `npm run dev` — this is the path the docs recommend.40- Put server-only/data-fetching logic in **`load` functions** (server variants for secrets/DB access) rather than in components.41- Use **form actions** with `<form>` for mutations to get progressive enhancement instead of hand-written client fetches.42- Choose the **adapter** that matches your deployment target so the build output fits the platform.4344## Common pitfalls45- Importing server-only code (secrets, DB clients) into universal modules → keep it in `*.server.*` files / server `load` so it never ships to the client.46- Expecting browser APIs to exist during SSR → guard with the `browser` check from `$app/environment` or run them in lifecycle hooks.47- Forgetting to install/configure an adapter for your host → add the matching deployment adapter before building for production.4849## Examples50```svelte51<!-- src/routes/+page.svelte -->52<script>53 export let data;54</script>5556<h1>{data.message}</h1>57```58```js59// src/routes/+page.server.js60export function load() {61 return { message: 'Hello from the server' };62}63```6465## Further reading66- Introduction: https://svelte.dev/docs/kit/introduction67- Adapters: https://svelte.dev/docs/kit/adapters6869## Related skills70- ../nuxt — Vue meta-framework with a comparable model71- ../astro — content-focused framework that also supports Svelte islands72- ../vite — the build tool SvelteKit is built on