Svelte March 2026: Programmatic Context, HTML Comments, and Server Error Boundaries

Svelte March 2026: Programmatic Context, HTML Comments, and Server Error Boundaries

lschvn

Svelte's March 2026 release lands a set of improvements that close longstanding gaps, most notably around programmatic component instantiation and server-side error handling, while continuing to refine SvelteKit's navigation APIs.

createContext Goes Programmatic

In Svelte 5, createContext and getContext let you share state across a component tree without prop drilling. The limitation was that context only worked with components rendered through Svelte's normal slot/transitions system. Calling new Component({ target }) to instantiate a component programmatically couldn't access the context map.

Svelte 5.50.0 fixes this. You can now pass a context Map as the third argument to the component constructor:

import { mount, setContext } from 'svelte';
import { MyContextKey } from './keys.js';

const ctx = new Map([[MyContextKey, { value: 42 }]]);
const component = new MyComponent({ target: document.body, props: {}, context: ctx });

This makes it practical to use Svelte components as plain JavaScript classes in libraries and testing utilities, without restructuring how context is provided.

HTML Comments Inside Tags, and TrustedHTML

Two compiler-level changes land in the same release train. HTML comments are now permitted inside HTML tag attributes:

<button 
  -- A comment inside the attribute list is now valid --
  class="primary"
  onclick={handler}>
  Click me
</button>

Simultaneously, {@html} expressions now accept TrustedHTML, part of the Web Secure Types API. This lets you tell the type system that a string has already been sanitized and should not trigger the usual any escape hatch when assigning to {@html}.

Error Boundaries Reach the Server

Error boundaries (svelte:boundary) previously only worked on the client. Svelte 5.53.0 extends them to server-side rendering, so you can catch and transform errors that occur during SSR without crashing the entire page. This matters for SvelteKit apps that fetch data at request time, a failing component no longer takes down the whole response.

SvelteKit: Navigation Callbacks Get Scroll Data

Navigation callbacks (beforeNavigate, onNavigate, afterNavigate) now include scroll position information on the from and to navigation targets. This enables scroll-aware transition animations, you can check whether the user is navigating back or forward and animate accordingly, all without extra bookkeeping.

The update also stabilizes Vite 8 support (kit@2.53.0) and adds an official better-auth addon to the Svelte CLI (sv@0.12.0).

State of JS 2025: Svelte Holds First Place

A quick vindication: the State of JS 2025 survey results are out, and Svelte retains its position as the top-ranked reactive framework in positive sentiment for the second consecutive year. The category includes Solid, Vue, React, Angular, and others, Svelte's developer satisfaction score continues to stand out.

Community Highlights

The usual round of notable projects built with Svelte this month:

  • Cherit: open-source markdown knowledge base built with Tauri
  • Mistral AI's worldwide hackathon site: built with Svelte, as noted on Reddit
  • Fretwise: AI-powered guitar practice platform generating tabs and isolated stems
  • SoundTime: self-hosted music streaming with P2P sharing, built with Rust + Svelte
  • warpkit: standalone Svelte 5 SPA framework with state-based routing and data fetching
  • svelte-grab: dev tool that captures component context for LLM coding agents, Alt+Click any element to inspect state and trace errors

Svelte's ecosystem continues to grow in directions that go well beyond the traditional web app, from music tools to hardware simulators to AI integrations.

Frequently Asked Questions

Related articles

More coverage with overlapping topics and tags.

Prettier 3.9 Overhauls Five Parsers: micromark for Markdown, yaml v2, GraphQL.js v17, a Rust-Based Flow Parser, and Angular
javascript

Prettier 3.9 Overhauls Five Parsers: micromark for Markdown, yaml v2, GraphQL.js v17, a Rust-Based Flow Parser, and Angular

Prettier 3.9.0, released June 27, 2026 (prettier/prettier, blog post by Fisker Cheung), is a parser-heavy release that upgrades Markdown from remark-parse v8 to micromark v4 (better CommonMark and GFM compliance and a stack of long-standing bug fixes), YAML to yaml v2, GraphQL to GraphQL.js v17 (fragment arguments and directives on directive definitions), Flow to the Flow team's new Rust-based oxidized parser (roughly 37% faster on Prettier's valid Flow fixtures and 43% faster on flow_parser.js in local parser-only benchmarks), and Angular. The JavaScript and TypeScript printer is reworked too, particularly in --no-semi mode where comments around break and continue are now stable across repeated formats (an idempotency fix), plus redundant parenthesis removal in return statements, embedded-template interpolation alignment, and logical-not inlining. The release drops the legacy import ... assert {} syntax (Babel 8 removed the parser plugin; migrate to with), fixes a silently broken --cache-strategy content option, and stops EditorConfig files above Git worktrees from leaking in. The team reiterates pinning the exact version in package.json because the formatting changes will produce diffs.
Biome 2.5 Ships with `@biomejs/js-api` v6.0.0: A Major Bump for the JS API
javascript

Biome 2.5 Ships with `@biomejs/js-api` v6.0.0: A Major Bump for the JS API

Biome's CLI hits 2.5.0 and the JavaScript API moves to a major v6.0.0. The headline is a new spanInBytesToSpanInCodeUnits helper that fixes a real bug in non-ASCII text extraction, plus a long list of SCSS, JSON, linter, and CLI improvements.
Astro 6.4.4 Patches Seven Bugs Across Routing, i18n, and Dev Experience
frameworks

Astro 6.4.4 Patches Seven Bugs Across Routing, i18n, and Dev Experience

Astro 6.4.4 is a patch release fixing issues with dynamic routes, i18n domain routing, client-side component editing, and route pattern casing.

Comments

Log in Log in to join the conversation.

No comments yet. Be the first to share your thoughts.