Getting Started
Render AutoForm with the TanStack Form adapter.
New to AutoForm? Check out the introduction first.
The TanStack Form route uses the same schema providers and UI packages as the React Hook Form route, but imports the form adapter from each package's tanstack-form subpath.
Install the AutoForm Agent Skill (optional)
If you use AI coding assistants (such as Cursor, Claude Code, OpenCode, or GitHub Copilot), you can install the AutoForm skill. It gives your coding agent access to AutoForm-specific documentation, examples, and best practices.
npx skills add https://github.com/vantezzen/autoform/tree/main/skills --skill autoformpnpm dlx skills add https://github.com/vantezzen/autoform/tree/main/skills --skill autoformyarn skills add https://github.com/vantezzen/autoform/tree/main/skills --skill autoformbunx --bun skills add https://github.com/vantezzen/autoform/tree/main/skills --skill autoformInstall AutoForm's form engine
Install TanStack Form and the AutoForm React base package:
npm install @autoform/react @tanstack/react-formpnpm add @autoform/react @tanstack/react-formyarn add @autoform/react @tanstack/react-formbun add @autoform/react @tanstack/react-formInstall AutoForm's integration to your UI library
AutoForm integrates directly into your UI library to render fields. Choose one official integration:
Shadcn/ui
npx shadcn@latest add https://raw.githubusercontent.com/vantezzen/autoform/refs/heads/main/packages/shadcn/registry/autoform-tanstack.jsonpnpm dlx shadcn@latest add https://raw.githubusercontent.com/vantezzen/autoform/refs/heads/main/packages/shadcn/registry/autoform-tanstack.jsonyarn shadcn@latest add https://raw.githubusercontent.com/vantezzen/autoform/refs/heads/main/packages/shadcn/registry/autoform-tanstack.jsonbunx --bun shadcn@latest add https://raw.githubusercontent.com/vantezzen/autoform/refs/heads/main/packages/shadcn/registry/autoform-tanstack.jsonUse the generated TanStack adapter export:
import { AutoForm } from "@/components/ui/autoform/tanstack-form";Material UI
{
"@mui/material": "^6",
"@mui/icons-material": "^6",
"@emotion/react": "^11",
"@emotion/styled": "^11"
}npm install @mui/material@^6 @mui/icons-material@^6 @emotion/react@^11 @emotion/styled@^11pnpm add @mui/material@^6 @mui/icons-material@^6 @emotion/react@^11 @emotion/styled@^11yarn add @mui/material@^6 @mui/icons-material@^6 @emotion/react@^11 @emotion/styled@^11bun add @mui/material@^6 @mui/icons-material@^6 @emotion/react@^11 @emotion/styled@^11npm install @autoform/muipnpm add @autoform/muiyarn add @autoform/muibun add @autoform/muiimport { AutoForm } from "@autoform/mui/tanstack-form";Mantine
{
"@mantine/core": "^7",
"@mantine/dates": "^7"
}npm install @mantine/core@^7 @mantine/dates@^7pnpm add @mantine/core@^7 @mantine/dates@^7yarn add @mantine/core@^7 @mantine/dates@^7bun add @mantine/core@^7 @mantine/dates@^7npm install @autoform/mantinepnpm add @autoform/mantineyarn add @autoform/mantinebun add @autoform/mantineimport { AutoForm } from "@autoform/mantine/tanstack-form";Ant Design
{
"antd": "^5"
}npm install antd@^5pnpm add antd@^5yarn add antd@^5bun add antd@^5npm install @autoform/antpnpm add @autoform/antyarn add @autoform/antbun add @autoform/antimport { AutoForm } from "@autoform/ant/tanstack-form";Chakra UI
{
"@chakra-ui/react": "^3.8",
"@emotion/react": "^11.14"
}npm install @chakra-ui/react@^3.8 @emotion/react@^11.14pnpm add @chakra-ui/react@^3.8 @emotion/react@^11.14yarn add @chakra-ui/react@^3.8 @emotion/react@^11.14bun add @chakra-ui/react@^3.8 @emotion/react@^11.14npm install @autoform/chakrapnpm add @autoform/chakrayarn add @autoform/chakrabun add @autoform/chakraimport { AutoForm } from "@autoform/chakra/tanstack-form";If you want to integrate into another UI library and create a custom package, check out the custom integration guide.
Install AutoForm's integration to your schema library
Zod
npm install @autoform/zodpnpm add @autoform/zodyarn add @autoform/zodbun add @autoform/zodYup
npm install @autoform/yuppnpm add @autoform/yupyarn add @autoform/yupbun add @autoform/yupJoi
npm install @autoform/joipnpm add @autoform/joiyarn add @autoform/joibun add @autoform/joiIn the docs, we use Zod as the schema example. Replace the schema provider import with the one for your schema library.
Create a form
"use client";
import * as z from "zod";
import { AutoForm } from "@autoform/mui/tanstack-form";
import { ZodProvider } from "@autoform/zod";
const mySchema = z.object({
name: z.string(),
age: z.coerce.number(),
birthday: z.coerce.date(),
});
const schemaProvider = new ZodProvider(mySchema);
export default function MyForm() {
return (
<AutoForm
schema={schemaProvider}
onSubmit={(data, form) => {
console.log(data); // Cleaned schema-parsed values
console.log(form.state.values); // Original raw TanStack values
}}
withSubmit
/>
);
}Common imports you may need:
// similar for yup or joi
import { ZodProvider, fieldConfig } from "@autoform/zod";
// Shared component types.
import type {
AutoFormFieldProps,
FieldWrapperProps,
ObjectWrapperProps,
ArrayWrapperProps,
ArrayElementWrapperProps,
} from "@autoform/react";
// For custom fields and form access.
import {
useFieldContext,
useFormContext,
} from "@autoform/react/tanstack-form";Next.js and RSC
AutoForm can only be used inside a client-side React component due to schema serialization and client form state. In a Next.js app, mark the component that renders AutoForm with "use client".
Submitting the form
Use withSubmit to render AutoForm's default submit button:
<AutoForm schema={schemaProvider} onSubmit={handleSubmit} withSubmit />You can also render your own submit button as a child:
<AutoForm schema={schemaProvider} onSubmit={handleSubmit}>
<button type="submit">Save</button>
</AutoForm>Accessing form data and methods
AutoForm exposes TanStack Form state and methods through:
onSubmit, where the second argument is the TanStack form API.useFormContext, for components rendered inside AutoForm.formControl, when a parent creates a form instance withuseAppFormand passes it into AutoForm.
See form control for examples.
Custom field components
When creating custom field components for the TanStack adapter, use useFieldContext from @autoform/react/tanstack-form. See customization.