[]previous and next page

useSubmit

A function that starts a submission of a server function on the page's store (its state then shows in useSubmission).

A function that starts a submission of a server function on the page's store (its state then shows in useSubmission). Use it for a mutation that is not a form: a button, a drag, an effect.

Import#

ts
import { useSubmit } from "@shadow-js/dusk/client";

Signature#

ts
function useSubmit(): (
  target: StubTarget,
  input: unknown,
  options?: ServerFnCallOptions & SubmitOptions,
) => Submission

Returns#

submit(target, input, options): returns the submission. options.revalidate: false skips the refresh of the loader data, and singleFlight functions are refreshed by their own answer.

Examples#

ts
const submitNote = useSubmit();
<button onClick={() => submitNote(saveNote, { title: "Draft" })}>Save</button>