3

svelte/5/components-as-functions-destroyfunction

How to Use
Run this codemod on your codebase using one of the following commands

The easiest way to run this codemod without installing anything globally:

Documentation

This codemod updates Svelte component instantiation and event handling for Svelte 5:

  • Converts new Component({ target }) to mount(Component, { target }).
  • Replaces $destroy method calls with unmount.
  • Ensures compatibility with Svelte 5's function-based components and new event handling.

Before

jsx

After

jsx

Ready to contribute?

Build your own codemod and share it with the community.