Samuel Ebuka ES

← Back

Article · 5 December 2022

Svelte vs Vue3

Svelte vs Vue3 epic battle.

Svelte vs Vue3 epic battle

▶ Svelte vs Vue3 (YouTube)

Svelte and Vue3 borrow a lot from each other. It is very clear when we look at their syntax. This is a good thing, frameworks are learning from each others mistakes and advantages.

Hello world !

Svelte


<script>
	let name = 'world';
</script>

<h1>Hello {name}!</h1>

Vue3

<script setup>
	let name = 'world'
</script>

<template>
  <h1>Hello {{ name }}!</h1>
</template>

Dynamic atributes

Svelte


<script>
	let src = 'https://svelte.dev/tutorial/image.gif';
	let name = 'Rick Astley';
</script>

<img src={src} alt="{name} dancing">

Vue3

<script setup>
	let src = 'https://svelte.dev/tutorial/image.gif';
	let name = 'Rick Astley';
</script>

<template>
 <img :src="name" :alt="`${name} dancing`"`
</template>

Styling

Svelte


<p>Styled!</p>

<style>
	p {
		color: purple;
		font-family: 'Comic Sans MS', cursive;
		font-size: 2em;
	}
</style>

Vue3


<template>
 <p>Styled!</p>
</template>

<style>
	p {
		color: purple;
		font-family: 'Comic Sans MS', cursive;
		font-size: 2em;
	}
</style>