Example - Simple Form
This is a simple example of an update form for the Items table. It doesn’t cover all the available features, but should give you a good starting point.- Passing your schema, db, entity name, and query will allow the form to be typesafe and automatically sync when changes are made
- Use the tanstack options to pass any custom options to the Tanstack Form instance. We automatically give you access to
handleIDBUpdateandhandleIDBCreatewhich can be called to automatically update/create in InstantDB with the latest values in the form.zodSchemais also automatically created for you based on your Instant schema. - Write your UI components using the
form.Fieldcomponent. This component is a wrapper around the Tanstack Form Field component, and automatically gives you typesafe field values.
TanStack Form Reference
Form state is managed under the hood using the@tanstack/react-form library with the useForm hook. See the docs for more information. You can pass all of the original useForm parameters to the tanstackOptions object. form.Field also uses the same API, so you have access to all tanstack form field values, such as field.state.meta
TanStack Form Docs
Read the reference for the useForm hook