Installation and Setup
Let's get TanStack Form installed and make sure everything is wired up before we build anything real.
Installing TanStack Form
Run this in your project root:
npm install @tanstack/react-form
Using pnpm or yarn? Same idea:
pnpm add @tanstack/react-form
# or
yarn add @tanstack/react-form
That's the only required dependency to get started.
TypeScript Configuration
TanStack Form is built with TypeScript in mind, and it works best with strict mode enabled. If you're starting a new project, make sure your tsconfig.json includes at least these settings:
{
"compilerOptions": {
"strict": true,
"moduleResolution": "bundler",
"jsx": "react-jsx"
}
}
Strict mode unlocks the best type inference — you'll get accurate types on your field values without having to annotate everything manually.
Installing Zod (for later)
In the validation section of this course we'll use Zod alongside TanStack Form's adapter. Go ahead and install both now so they're ready when we need them:
npm install zod @tanstack/zod-form-adapter
You won't need these right away, but it's nice to have them in place.
Project Structure
Any standard React + TypeScript setup works fine. If you're starting fresh, Vite is the quickest way to get going:
npm create vite@latest my-app -- --template react-ts
cd my-app
npm install
npm install @tanstack/react-form zod @tanstack/zod-form-adapter
Create React App works too, though Vite is faster and more actively maintained these days.
Verifying the Install
Let's make sure everything is working. Drop this into src/App.tsx:
import { useForm } from '@tanstack/react-form'
function App() {
const form = useForm({
defaultValues: {},
onSubmit: async ({ value }) => {
console.log(value)
},
})
return <div>TanStack Form is ready!</div>
}
export default App
Run the dev server and if you see "TanStack Form is ready!" without any TypeScript errors or import complaints, you're good to go.
That's all the setup you need. From here, you have a clean project ready to build your first form.