What is the TypeScript definition for the onSubmit event in React?

The right interface for onSubmit is FormEvent

Please continue reading below to see how to use it or read my guide on using React events with TypeScript.

You can also go to the search page 🔍 to find another event.

Interface

interface FormEvent<T = Element> extends SyntheticEvent<T> {
}

Full example

import React, { FormEvent } from 'react';

const FormComponent = () => {
  const handleFormEvent = (e: FormEvent<HTMLFormElement>) => {
    // Do something
  };

  return <form onSubmit={handleFormEvent}>{/** Some JSX */}</form>;
};

export default FormComponent;

Attributes that use FormEvent:

Get notified about new tutorials

Join over 1,000 developers who receive React and JavaScript tutorials via email.

No spam. Unsubscribe at any time.