Migration Guide
Learn how to migrate from Formsnap v1 to v2.
Formsnap v2 has been rewritten to support Svelte 5 and with that, comes some breaking changes. This guide will help you migrate your codebase to the new version, one component at a time.
At the time of writing this guide, sveltekit-superforms
still functions the same as it did for v1, so you won't need to make any changes to the Superforms-specific code.
Universal Changes
The changes in this section apply to a number of components in Formsnap, and are not specific to any one component.
asChild -> child Snippet
In v1, the asChild
prop could be used on any component that rendered an HTML element under the hood to opt out of rendering the element to provide your own.
In v2, this prop has been removed completely in favor of the child
snippet, which is available for all components that render an HTML element, and exposes a props
snippet prop that you can spread onto your own element/component.
You can learn more about the child
snippet in the child documentation.
el -> ref
In v1, you could bind to the el
prop of any component that rendered an element to receive a reference to that HTML element.
In v2, this prop has been replaced by the ref
prop, which is available for all components that render an HTML element, and exposes a $bindable
reference to the underlying HTML element.
Slot Props -> Snippet Props
In v1, the various *Field
components provided a number of slot props for your convenience, such as value
, errors
, tainted
, and constraints
.
In v2, the *Field*
components now provide those values via snippets props to the children
snippet that you can use when needing to access those values.
Control
The Control
component in v1 simply expose an attrs
slot prop that was spread onto the control element, like so:
In v2, the Control
component now provides those attributes via a children
snippet prop, like so:
This change comes with Svelte's deprecation of <slot />
and slot props in favor of Snippets.