Svelte and SvelteKit 5 · Template syntax

Reusable markup with snippets

Define a snippet once and render it where you need it, with parameters.

{#snippet row(item)}
  <li>{item.name} - {item.price}</li>
{/snippet}

<ul>
  {#each products as product}
    {@render row(product)}
  {/each}
</ul>

Official Svelte and SvelteKit 5 documentation

More template syntax commands

All template syntax commands · Svelte and SvelteKit 5 cheatsheet

Was this page helpful?