-
-
Notifications
You must be signed in to change notification settings - Fork 94
Description
Problem/Motivation
SvelteKit has introduced a new concept of "Remote Functions" (specifically the form
type) as discussed in sveltejs/kit#13897. These functions aim to provide a type-safe, collocated, and progressively enhanced way to handle server-side data mutations, acting as a SvelteKit-native RPC layer.
Currently, Superforms excels at providing an excellent DX for forms, including validation, progressive enhancement, and data binding. However, with the release of remote functions, there's an opportunity to further streamline the server-side action handling within Superforms, potentially simplifying boilerplate and improving type inference for form actions.
Proposed Solution/Idea
Explore and design an integration strategy for Superforms to leverage SvelteKit's new remote functions, particularly the form
type. This could involve:
- Dedicated Handler: Provide an API within Superforms that allows users to directly bind a Superform to a SvelteKit remote
form
function, reducing the need for explicitactions.ts
files or manualfetch
calls for mutations. - Enhanced Type Inference: By understanding the types exposed by remote functions, Superforms could potentially offer even more robust and automatic type inference for form data and responses.
- Simplified Mutation Logic: Abstract away some of the repetitive patterns in
+page.server.ts
or+page.ts
action handling when remote functions are used for form submissions.
This integration could lead to an even more cohesive and "SvelteKit-native" feel for Superforms users, aligning with SvelteKit's evolving patterns for data handling.
Benefits
- Reduced Boilerplate: Simplify server-side form handling.
- Improved Type Safety: Leverage remote functions' strong typing.
- Enhanced Developer Experience: More intuitive and integrated approach to form mutations.
- Future-Proofing: Align Superforms with SvelteKit's direction for data mutations.
Relevant Links
- SvelteKit Remote Functions Discussion: Remote Functions sveltejs/kit#13897