Skip to main content
Svelte 5 introduces significant improvements to reactivity, component architecture, and developer experience. This guide will help you migrate your Svelte 4 application to Svelte 5.

Overview of Major Changes

Svelte 5 brings several fundamental changes:
  • Runes: New reactive primitives replace legacy reactive syntax
  • Components as functions: Components are now functions, not classes
  • Snippets: Replace slots for content composition
  • Event handlers: Use callback props instead of createEventDispatcher
  • Props: New $props() rune replaces export let

Breaking Changes

The following Svelte 4 patterns are deprecated or removed in Svelte 5:
  • $: reactive statements (use $derived and $effect)
  • export let for props (use $props())
  • createEventDispatcher (use callback props)
  • <slot> elements (use snippets)
  • on: event directive (use event attributes)
  • Components as class instances (now functions)

Migration Strategy

Incremental Migration

Svelte 5 supports both legacy mode and runes mode, allowing you to migrate incrementally:
  1. Update Svelte: Install Svelte 5
  2. Component by component: Migrate one component at a time
  3. Test thoroughly: Ensure functionality remains intact
  4. Update dependencies: Check third-party packages for Svelte 5 compatibility

Automatic Migration

Svelte provides migration tools to help automate the process. Run the migration script on your codebase to get started.

Reactivity Changes

From $: to Runes

Svelte 4’s reactive statements ($:) are replaced by $derived and $effect runes.

State Management

Props Changes

From export let to $props()

export let is deprecated in runes mode. Use the $props() rune instead.

Bindable Props

Event Handling Changes

From createEventDispatcher to Callbacks

createEventDispatcher is deprecated in Svelte 5. Use callback props instead.

Event Directives

Component API Changes

Components as Functions

In Svelte 5, components are functions, not class instances. This means:
  • No new Component() syntax
  • No component.$set() or component.$on() methods
  • Use mount() and unmount() for programmatic rendering

Slots to Snippets

Basic Content Projection

Named Slots

Scoped Slots (Render Props)

Lifecycle Changes

Store Changes

Stores continue to work in Svelte 5, but you may want to migrate to runes for better performance:

TypeScript Changes

Update your TypeScript types for Svelte 5:

Common Migration Patterns

Two-Way Binding

Component Composition

Migration Checklist

  • Update to Svelte 5
  • Replace $: with $derived and $effect
  • Convert export let to $props()
  • Replace createEventDispatcher with callback props
  • Update on: directives to event attributes
  • Convert <slot> to snippets and {@render}
  • Update component instantiation (use mount)
  • Update lifecycle hooks (use $effect where needed)
  • Update TypeScript types
  • Test all components thoroughly
  • Update documentation

Next Steps