🎞️ Animated Routes

How to animate route transitions in SvelteKit

Animated Route Component

lib/components/AnimatedRoute.svelte
<script>
    import { fly} from "svelte/transition";
    import { page } from "$app/stores";
</script>

{#key $page.url}
  <div in:fly={{  x:'-100%', duration: 500 }}>
    <slot  />
  </div>
{/key}

Login Layout

login/+layout.svelte
<AnimatedRoute>
  <main>
    ...
  </main>
</AnimatedRoute>

Questions? Let's chat

Open Discord