Svelte 5 New `{let/const}` Declaration Tags

Микита ТарановMay 30, 2026 at 2:13 AM

Svelte@5.56,0 Svelte@5.56,0 New href="https://svelte.dev/docs/declaration-tags" target="_blank" rel="nofollow noopener noreferrer">{let/const ...} - a more powerful alternative {@const ...}:  1. You can declare it anywhere {const hello = 'hello'} {hello} {const hello = 'hi'} {hello}   {hello} {hello} 2. It can be used with $state and $derived {#if editing}   {let name = $state(user.name)}   {const greeting = $derived(Hello ${name})}

{greeting}   { user.name = name; editing = false; }}>save {/if}

El Psy KongrooMay 30, 2026 at 2:17 AM

Funny, but very strange, especially with the state. I don’t like to interfere with logic.

Misha RodshteinMay 30, 2026 at 2:30 AM

The cow!

Denis ChernovMay 30, 2026 at 7:46 AM

I am not cursing this reality.

Misha RodshteinMay 30, 2026 at 9:07 AM

What does not like this?

Denis ChernovMay 30, 2026 at 9:07 AM
I don't like to bother tagging with logic
Микита ТарановMay 30, 2026 at 2:20 AM

But now the snippets can have their state.

El Psy KongrooMay 30, 2026 at 2:38 AM

It makes sense, but it still seems to be a bit of a bit and for this it seems like another mechanism has to be invented.

Denis ChernovMay 30, 2026 at 9:07 AM

Here is purely my position that the patterns should be as dumb as possible, and everything else is expressed either by logic or composition.

Misha RodshteinMay 30, 2026 at 9:22 AM

This is uncomfortable.When you do a lot of stuff, it becomes clear very quickly.

Denis ChernovMay 30, 2026 at 9:23 AM

When there is just a logic inside the templates and there should not be a lot to divide into components - a straight base to keep the balance of logic in the templates.

Misha RodshteinMay 30, 2026 at 9:24 AM

No, not the base. It all depends on the situation.

Denis ChernovMay 30, 2026 at 9:30 AM

The script is only needed for imports.

Misha RodshteinMay 30, 2026 at 9:56 AM

Well, no, just sometimes you need some microcomputing, and it’s not convenient to carry them into scripts.

Gleb WintersonMay 30, 2026 at 9:27 AM

And eventually the old syntax {@const ...} will be deprecated?

Denis ChernovMay 30, 2026 at 9:29 AM

Am what is it?

Gleb WintersonMay 30, 2026 at 9:30 AM

What’s the point of leaving it? it’s confusing.

Denis ChernovMay 30, 2026 at 9:31 AM

In the script, you can confuse both reactive and non-reactive variables.

Gleb WintersonMay 30, 2026 at 9:31 AM

No yes, but that’s something else.

Denis ChernovMay 30, 2026 at 9:32 AM

Sorry, you are right.

Gleb WintersonMay 30, 2026 at 9:32 AM

That would be logical, or it would just be a confusion.

Denis ChernovMay 30, 2026 at 9:33 AM

Yes, apparently breaking changes were scared and didn't want 6 apaths because of this.

Gleb WintersonMay 30, 2026 at 9:33 AM

They seem to go away a little bit.

Denis ChernovMay 30, 2026 at 9:33 AM

There is no perfection anywhere except let/const.

Misha RodshteinMay 30, 2026 at 9:58 AM

There may be a problem with reasoning on this topic.

Denis ChernovMay 30, 2026 at 9:58 AM

Yes, it would be interesting to read now the only guess - the departure from breaking changes with the existing @const

Misha RodshteinMay 30, 2026 at 10:00 AM
Denis ChernovMay 30, 2026 at 10:02 AM

By the way, in this regard, in the first case, we have a sequential calculation and everything is OK, and in the second we produce new elements in the reactive chart for each list re-render?

Микита ТарановMay 30, 2026 at 1:13 PM

Because it’s just a piece of JS, there’s no special transformation.

Антон ЧанновMay 30, 2026 at 10:46 AM

In a few years, JSX will be over.

Denis ChernovMay 30, 2026 at 10:53 AM

The tsrx model is closer.