Creates an action for progressively enhanced forms that handles validation and submission on the server.

// Form action for simple forms
formAction$<Values, ResponseData>(action, validate);

// Form actions for complex forms
formAction$<Values, ResponseData>(action, options);



If you use TypeScript, you should define your field values. This way the library knows exactly which fields your form has and what values they expect. It also allows autocompletion and TypeScript notifies you of typos.

It is recommended to use type instead of interface as this currently requires an explicit index signature in TypeScript. More about this here.



The action function is only executed if the form values have passed the validation. Since validate is executed on the server, the validation cannot be manipulated by the user. You can use the action function to process the form values and store them in a database, for example. Also you can manipulate the state of the form action via the return value or send a message to the client via the FormResponse object.

Using arrays, booleans, files and numbers you can suplement information that is lost when submitting the form without JavaScript. You can find more about this here.