Reference
Form
Form
Form wraps SvelteKit's form(...). The return value is spreadable
onto a <form> element exactly like SvelteKit's native form, with the
I/O surfaces overridden to be Effect-shaped.
import { Form } from "svelte-effect-runtime";EffectForm
type EffectForm<Input, Output, Error = never> =
& Omit<RemoteForm<Input, Output>, "enhance" | "validate" | "for">
& {
native: RemoteForm<Input, Output>;
submit(
data: OptionalArgument<Input>
): Effect<Output, RemoteFailure<Error>, never>;
enhance(
callback: (args: {
form: HTMLFormElement;
data: Input;
submit: () => Effect<void, RemoteFailure<Error>, never>;
}) => Effect<unknown, unknown, never> | void
): { method: "POST"; action: string; [attachment: symbol]: ... };
validate(options?: {
includeUntouched?: boolean;
preflightOnly?: boolean;
}): Effect<void, RemoteFailure<Error>, never>;
for(id): EffectForm<Input, Output, Error>;
};The non-overridden properties from RemoteForm (method, action,
fields, result, pending, preflight, the @attach symbol) keep
their SvelteKit semantics.
Form overloads
interface EffectFormFactory {
// No-arg.
<Output, ErrorType, Requirements>(
fn: () => Effect<Output, ErrorType, Requirements>
): EffectForm<void, Output, ErrorType>;
// Unchecked — caller-supplied input shape.
<Input extends RemoteFormInput, Output, ErrorType, Requirements>(
validate: "unchecked",
fn: (args: {
data: Input;
invalid: Invalid;
}) => Effect<Output, ErrorType | FormError, Requirements>
): EffectForm<Input, Output, ErrorType>;
// Schema-validated.
<SchemaType extends EffectSchema, Output, ErrorType, Requirements>(
validate: SchemaType,
fn: (args: {
data: SchemaOutput<SchemaType>;
invalid: Invalid<SchemaType>;
}) => Effect<Output, ErrorType | FormError<SchemaType>, Requirements>
): EffectForm<SchemaInput<SchemaType> & RemoteFormInput, Output, ErrorType>;
}Invalid
The proxy passed into a form handler for producing validation issues:
type Invalid<SchemaType = unknown> = {
form: (message: string) => Effect<never, FormError<SchemaType>, never>;
} & {
[Field in keyof SchemaOutput<SchemaType>]: (
message: string
) => Effect<never, FormError<SchemaType>, never>;
};Yield invalid.<field>(message) to attach an issue to a specific field
or invalid.form(message) for a top-level one. Schema-backed forms get
typed field helpers derived from the schema's output shape.
See the Form guide for usage and the
errors reference for RemoteFailure<E>.