In Svelte 3 and 4, components were classes, while in Svelte 5, components are functions. This codemod updates the instantiation of Svelte components to use mount
or hydrate
(imported from svelte), ensuring compatibility with Svelte 5's new functional component model.
Before
import App from './App.svelte';const app = new App({ target: document.getElementById('app') });export default app;
After
import { mount } from 'svelte';import App from './App.svelte';const app = mount(App, { target: document.getElementById('app') });export default app;
Build custom codemods
Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community