{#if} {#else if} {#else}
Conditionally render markup based on JavaScript expressions.
Conditional Blocks
Svelte conditionals look like Handlebars: {#if}, {:else if}, {:else}, closed with {/if}.
Basic Example
Show one branch or another based on a boolean expression.
{#if loggedIn}
<p>Welcome back!</p>
{:else}
<p>Please sign in.</p>
{/if}All lessons in this course
- {#if} {#else if} {#else}
- {#each} with Index and Key
- {#key} for Forcing Re-render
- Nested {#each} and Keyed Updates