Forms

GET forms swap like a link. POST does a normal submit – bring HTMX or Turbo if you need no-reload posts.

Sparke treats GET forms like links and leaves everything heavier to the browser or your other tools.

GET forms

GET forms are intercepted and swapped like a link – the fields are serialized into the query string, and the result page swaps in from the network (or memory, if already preloaded).

Because Sparke preloads GET targets while idle, any action with a side effect (logout, delete, unsubscribe) must be POST - never a GET link or form. See Side-effect routes.

POST and other methods

POST and other methods do an ordinary full submit. If you need no-reload POSTs, use HTMX or Turbo alongside Sparke. Forms carrying hx-* attributes are skipped so HTMX stays in charge. This is also why side-effect actions belong here as POST: Sparke leaves them entirely to the browser and never fires them speculatively.

You can guard navigation with the cancelable sparke:before-swap event – handy for unsaved-changes prompts.

Confirm unsaved changesjs
window.addEventListener("sparke:before-swap", (e) => {
  if (formIsDirty() && !confirm("Leave with unsaved changes?"))
    e.preventDefault();
});

Restoring values

Form values (text, selects, checkboxes/radios) are restored on Back/Forward, matching the browser's back-forward cache. File and password fields are not.