Formify Docs

Confirm Dirty

The confirmDirtyPlugin — warn before leaving with unsaved changes

Confirm Dirty

confirmDirtyPlugin warns before the user leaves the page while the form has unsaved changes.

Usage

import { confirmDirtyPlugin } from "formify-js";

plugins: [
  confirmDirtyPlugin({
    message: "You have unsaved changes — leave anyway?",
  }),
]

Options

OptionTypeDefaultDescription
messagestringbrowser defaultText shown in the beforeunload prompt.

Things to know

  • Registers a beforeunload listener on mount and removes it on unmount.
  • Only warns while the form is dirty (values differ from initialValues).

On this page