Svelte 5.52.0 adds TrustedHTML support for {@html}, enabling safer Trusted Types integration
Svelte 5.52.0 (published Feb 18, 2026) introduces first-class support for TrustedHTML objects in {@html} blocks: Svelte will accept and preserve TrustedHTML values instead of coercing them to strings, making it easier to adopt browser Trusted Types APIs and reduce XSS risk when rendering raw HTML. (github.com)
Why this matters for full-stack teams
- Trusted Types are a browser‑level defensive mechanism that prevents DOM XSS by requiring that sinks which accept HTML (like innerHTML) receive values created by an approved policy. Framework-level support means you can now wire Svelte's server/client flow into that model without having the framework silently convert a TrustedHTML object back into an untrusted string—removing a class of accidental regressions. (github.com)
- For SSR + hydration apps, this reduces surprises where server-rendered markup and client-side policies interact. Teams using Content-Security-Policy: require-trusted-types-for 'script' (and related policies) can adopt Trusted Types more practically with Svelte in place. (github.com)
Practical, high-impact upgrade checklist
- Upgrade to [email protected] (or later).
- Audit uses of {@html}: treat any existing raw-HTML sinks as security-sensitive and prefer producing TrustedHTML values from known-safe sources where feasible.
- For client-only Trusted Types:
- Create HTML via a trusted policy in the browser (policy.createHTML(...)) and pass that TrustedHTML to components that render {@html}.
- Enable CSP Trusted Types policies in production only after testing locally.
- For SSR scenarios:
- Prefer producing sanitized strings server-side (e.g., DOMPurify) and, on first client activation, convert to TrustedHTML via a browser policy before further DOM operations—so server output remains safe while still interoperating with client Trusted Types.
- Alternatively, use safe serialization patterns and have client-side code reconstruct TrustedHTML through an allowlisted policy during hydration.
- Test thoroughly: enable require-trusted-types-for in staging CSP to surface any places where untrusted strings are still used.
Migration pitfalls and guidance
- TrustedHTML is a browser runtime object; servers cannot create a browser TrustedHTML instance directly. The release avoids coercion, but it does not magically make server-created strings automatically TrustedHTML on the client—your app must create TrustedHTML client-side (or use an explicit, audited serialization → policy.createHTML flow during hydration).
- Do not rely on framework coercion to sanitize content. TrustedHTML support reduces friction for adopting Trusted Types, but you still need sane sanitization and an explicit trust model for any content from users or third parties. (github.com)
Bottom line This Svelte release is a practical, ground-level improvement for teams hardening web apps against XSS: it removes a framework-level impedance mismatch with Trusted Types and makes adopting browser-native defenses more straightforward—especially important for full‑stack apps that SSR and hydrate complex markup. Treat this as an opportunity to audit {@html} usage, adopt or tighten sanitization policies, and plan a staged rollout of Trusted Types in staging before enabling strict CSP in production. (github.com)
Source:
Source
Read Next
Next.js 16 makes Turbopack stable and the default for dev and build
February 20, 2026Next.js 16 moves Turbopack to stable/default, raises the Node.js minimum, and ships production-facing caching primitives — what full‑stack teams must change now.
Vite 8.0.0‑beta.14 adds server‑side .wasm?init (WASM SSR) and updates Rolldown to 1.0.0‑rc.4
February 19, 2026Vite's Feb 12, 2026 beta introduces SSR support for pre-initialized WebAssembly modules and upgrades its bundler integration to Rolldown 1.0.0‑rc.4 — a practical change that reduces client hydration work and improves tooling stability for Wasm-heavy server renders.
React Native 0.84 Released — Hermes V1 Becomes the Default, Prebuilt iOS Binaries and Legacy‑Arch Removal
February 18, 2026React Native 0.84 makes Hermes V1 the default JavaScript engine, ships precompiled iOS binaries by default, removes remaining Legacy Architecture components, and raises the Node requirement — immediate actions for full‑stack teams.