Contact

Tools  /  Generators  /  Svelte Component Generator

Svelte Component Generator

Scaffold a Svelte component — Svelte 5 runes ($props / $state / $derived / $effect / $bindable / snippets) or Svelte 4 (export let / $: / createEventDispatcher / slots), JS or TS, with typed props, defaults, two-way binding, state and styling — plus an optional test and a usage example.

What this tool does

It writes a complete Svelte component from a name and a prop list, in either the Svelte 5 runes syntax or the classic Svelte 4 style.

Svelte 5 vs Svelte 4

Svelte 5 uses runes: let { title } = $props(), let count = $state(0), const doubled = $derived(count * 2), $effect(() => …), $bindable() for two-way props, and {#snippet} / {@render} instead of slots. Svelte 4 uses export let, reactive $: statements, createEventDispatcher and <slot>.

Props and types

In TypeScript, Svelte 5 props are typed with an interface Props passed to $props<Props>(); Svelte 4 annotates each export let.

Events

Svelte 5 favours callback props (onsave is just a function prop you call). Svelte 4 uses createEventDispatcher and the consumer listens with on:save.

Privacy

Everything runs in your browser. Nothing is uploaded.

Frequently asked questions

Should I pick Svelte 5 or Svelte 4?
Svelte 5 (runes) for any new project — it is the current major version. Choose Svelte 4 only if your app has not migrated yet.
How do two-way bindable props work?
In Svelte 5 a prop declared value = $bindable() can be bound by the parent with bind:value. In Svelte 4 any export let prop is bindable the same way.
What replaced slots in Svelte 5?
Snippets. A default slot becomes a children snippet rendered with {@render children?.()}; named slots become named snippet props.
Can it generate a test?
Yes — a Vitest file using @testing-library/svelte that renders the component and checks a prop appears. Enable the test file.
Is anything sent to a server?
No. The component is assembled entirely in your browser.
Theme Accent