Simple Form
Render forms with validation and submission
This library uses Tanstack Form under the hood. It works by letting you pass configurable options related to InstantDB, and also allows passing any custom options to Tanstack Form. It then handles updates and syncing for you.
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
handleIDBUpdate
andhandleIDBCreate
which can be called to automatically update/create in InstantDB with the latest values in the form.zodSchema
is also automatically created for you based on your Instant schema. - Write your UI components using the
form.Field
component. 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
In the next page, we’ll cover a more complex example with all of the available features, including creating a reusable component that works for both create and update forms, handling relationship picker fields, debouncing, and more.