Skip to content
Back to skills

Svelte Knowledge Patch

ASecurity

Svelte

  • 25 stars
  • 0 votes
  • 0 copies
  • 7 views
  • Added September 5, 2026
developmenttypescriptrustgoreactnodeexpressdebuggingsecurity

Works with

  • cli

Security analysis

A100/100

Pro scans all 8 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Nevaberry/nevaberry-plugins --skill svelte-knowledge-patch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Svelte Knowledge Patch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Svelte Knowledge Patch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nevaberry-svelte-knowledge-patch-nevaberry-plugins/badge)](https://www.skillsdirectory.com/skills/nevaberry-svelte-knowledge-patch-nevaberry-plugins)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: svelte-knowledge-patch
description: Svelte
version: null
license: MIT
metadata:
  author: Nevaberry
---


# Svelte knowledge patch

Load this skill when migrating Svelte or SvelteKit, working with reactive
components, handling remote forms and queries, or configuring builds and
deployments. Use the topic references for complete guidance and examples.

> [!CAUTION]
> Prerelease guidance may change before stable release. Affected guidance
> is marked individually.

## Topic index

| Reference | Topics |
| --- | --- |
| [Svelte 5 migration](references/svelte-5-migration.md) | Upgrade sequence, Vite plugin, component migrator, slots and snippets |
| [Runes and components](references/runes-and-components.md) | State, effects, async work, context, templates, boundaries, CSS, accessibility, inspection |
| [Remote forms](references/remote-forms.md) | Schemas, nested values, validation, submissions, resets, redirects, uploads |
| [Remote queries and commands](references/remote-queries-and-commands.md) | Optional inputs, template awaits, refreshes, live queries, response errors |
| [SvelteKit routing and runtime](references/kit-routing-and-runtime.md) | Paths, matchers, navigation, endpoints, error pages, security, observability |
| [Tooling, build, and deployment](references/tooling-build-and-deployment.md) | SvelteKit migration, configuration, environment variables, service workers, prerendering, adapters |

## Migration and compatibility checks

### SvelteKit migration requirements

> **Prerelease (`3`):** This guidance may change before stable release.

SvelteKit 3 requires Svelte 5 and Vite 8. The migrator applies supported
changes and generates a TODO list for the rest:

```sh
npx sv@next migrate sveltekit-3 --tasks all --confirm
```

To start a new app on the release candidate, run `npx sv@next create my-new-app`.

### SvelteKit configuration location

> **Prerelease (`3`):** This guidance may change before stable release.

Move SvelteKit configuration from `svelte.config.js` into `vite.config.ts`.

### Shared-code imports

> **Prerelease (`3`):** This guidance may change before stable release.

Replace `$lib` imports with Node subpath imports under `#lib`. Spell out the
filename and extension, including `index.ts` for a directory entry point.

### Generated TypeScript base

> **Prerelease (`3`):** This guidance may change before stable release.

Set `extends` to `$app/tsconfig` in the app's `tsconfig.json`. The generated
base supplies more recommended compiler options. The app config should
specify `include` and `exclude` explicitly, with the service worker excluded.

### Service-worker imports and types

> **Prerelease (`3`):** This guidance may change before stable release.

Replace `$service-worker` imports with the corresponding exports from
`$app/env`, `$app/paths`, and `$app/manifest`. For typed worker events, import
`self` from `$app/service-worker`; put a `tsconfig.json` alongside the worker
that extends `$app/tsconfig/service-worker`.

### Explicit environment variables

> **Prerelease (`3`):** This guidance may change before stable release.

Remove the experimental opt-in. Declare explicit environment variables in
`src/env.ts`, choosing which are public and which resolve at build time or
application startup. Standard Schema validators can validate the declared values.

### Svelte component upgrades

For projects on Svelte 3, complete the Svelte 4 migration before upgrading to
Svelte 5. The Svelte 5 upgrade pairs `svelte@^5` with
`@sveltejs/vite-plugin-svelte@^4.0.0`.
With a component open in VS Code and the Svelte extension installed, run
**Migrate Component to Svelte 5 Syntax** from the Command Palette.

Svelte 5.57.2 rejects `let:` directives on a component invocation that also
supplies a `children` snippet. When migrating a default slot, pass its values
as arguments to the snippet and declare them as snippet parameters.
Its migrator preserves a dependency-free `$:` assignment when it cannot
convert it to a declaration; check the retained assignment when finishing migration.

### Imports and ambient types

SvelteKit 2.70.0 moves `defineEnvVars` to `@sveltejs/kit/env`; update the import
in the environment variable configuration.
Svelte 5.57.0 lists `@types/trusted-types` as a development dependency. If the
application relies on ambient types such as `TrustedHTML` from that package,
declare it as a direct development dependency.

## Reactive components and asynchronous rendering

### Initialization before awaiting

Starting in Svelte 5.58.1, experimental async mode requires `getAbortSignal()`
to run before the first `await` in the active effect or derived calculation.
Capture the signal before suspending and pass it to the asynchronous work.
During server rendering, calling `setContext()` after an `await` throws
`set_context_after_init`; set context before the component's first `await`.
Svelte supports experimental asynchronous server rendering.

### Immediate feedback and pending work

Use `$state.eager(value)` for immediate feedback after a user action when an
`await` expression would otherwise delay the UI update. It retains its eager
behavior in a variable initializer such as `const current = $state.eager(value)`.
`$effect.pending()` counts pending promises from component `await` expressions
in the current `<svelte:boundary>`; each nested boundary has its own count.
In Svelte 5.58.1, `$inspect` and `$state.eager` exclude a fork's speculative
values until the fork commits.

### Typed context and reactive collections

`createContext<T>()` returns a third function that checks whether the context
is available; call it during component initialization before reading optional context.
`SvelteMap` from `svelte/reactivity` supports `getOrInsert(key, value)` and
`getOrInsertComputed(key, callback)`. Both return the entry's value; the computed
variant calls its callback with the key only when the entry is missing.

### Error-boundary behavior

SvelteKit allows `<svelte:boundary>` to catch errors from its contents during
server rendering and render its `failed` snippet as a fallback.
When hydrating a boundary that failed during server rendering, Svelte 5.56.8
calls `onerror` and supplies a working `reset` callback.
Svelte 5.57.2 ignores stale `reset` callbacks; use the callback for the current
failure to retry rendering. Svelte 5.59.2 catches errors thrown while rendering
a deferred `{#await}` branch in its surrounding `<svelte:boundary>`.

## Remote forms

### Nested values and optional fields

In SvelteKit 2.53.2, `form.fields.set(...)` accepts incomplete nested objects,
and `form.fields.value()` is typed to reflect missing nested fields. Nested
values set this way appear in the server-rendered form before hydration.
An unchecked checkbox is omitted from a submission: make its boolean schema
field optional and supply a default if the handler needs a boolean.
Remote form data omits file inputs with no selected file; an optional upload's
schema should accept a missing field.

### Validation and reset behavior

Chain `.preflight(schema)` before `.for(id)` to keep preflight validation
active on a keyed form instance.
`fields.branch.issues()` returns `undefined` when the only issues are on
`fields.branch.leaf`; read the leaf field's `issues()` to display those messages.
Resetting a remote form clears validation issues and touched state. SvelteKit
waits a tick before resetting a submitted form, so code observing the automatic
reset can still see submitted values until that tick.

### Submission feedback and redirects

Remote forms expose `submitted` for conditional submission feedback.
When a remote form submission redirects, SvelteKit follows the form's `target`
attribute when navigating to the destination.

## Remote queries and commands

Remote `query`, `command`, and `prerender` accept schemas with optional input
in SvelteKit 2.53.2. The handler can use a default when validated input is `undefined`.
A remote function call in a template no longer delays server rendering unless
the template awaits it. Use `await` when rendering needs the result.
A remote query can refresh another remote query while it runs.

Existing `for await...of` loops stay subscribed across `query.live` reconnects.
A reconnected stream that finishes without yielding preserves the last value;
the reconnect promise also settles on offline or interrupted attempts so
`invalidateAll()` can finish.
SvelteKit 2.65.2 preserves transport failures' HTTP status and error body.
Consuming a remote failure through `current` and `error` avoids an unhandled
promise rejection in that version.

## Routing and runtime

### Expected errors in reporting hooks

> **Prerelease (`3`):** This guidance may change before stable release.

The `handleError` hook also receives deliberate `error(...)` calls. Account
for expected HTTP errors when logging or reporting from the hook.

### Shallow navigation

> **Prerelease (`3`):** This guidance may change before stable release.

Use `goto` with `shallow: true` in place of `pushState` and `replaceState`.
Shallow navigation runs navigation hooks such as `beforeNavigate`, and
`persistState: true` keeps page state across a reload.

### Paths and parameters

`resolve()` from `$app/paths` accepts a pathname with a search string, a hash,
or both, such as `resolve('/products?sort=price#results')` for a `/products` route.
A route matcher's TypeScript type predicate narrows its page or layout parameter
in `$app/types`, with the narrower type carried through to `$app/state` and hooks.

## Build and debugging reminders

SvelteKit skips the client build when every route has `csr` disabled.
Prerendering fails in SvelteKit 2.65.2 if root `src/routes/+server.js` returns
a non-HTML response; serve prerendered JSON or other non-HTML responses from
a non-root route. Marking a route containing both `+page` and `+server` as
prerenderable fails early.

Pass `vite-plugin-svelte` options to `sveltekit()` in `vite.config.js`.
Initialize server observability in `instrumentation.server.ts`; SvelteKit can
emit OpenTelemetry traces.
In development, put `$inspect.trace()` first in a function body to log the
reactive state that caused it to run again as part of an effect or derived
value, including helper functions called by the reaction.

Files in this skill

  • SKILL.md9.1 KB
  • coverage.json1.6 KB
  • references/kit-routing-and-runtime.md3.1 KB
  • references/remote-forms.md1.8 KB
  • references/remote-queries-and-commands.md2.1 KB
  • references/runes-and-components.md6.2 KB
  • references/svelte-5-migration.md701 B
  • references/tooling-build-and-deployment.md2.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.