Welcome to this step-by-step tutorial on building a multi-step form in Next.js using React Hook Form, Chakra UI, and Zod for validation. By the end of this tutorial, you'll have a fully functional onboarding form that supports browser navigation, and a seamless user experience.
📺 Check out the tutorial on YouTube (https://www.youtube.com/playlist?list=PLx2Y9Sna27XuKM4RDa0kfn5tqDp75zSOI)
✅ Setting up Chakra UI v3 in a Next.js project
✅ Creating multi-step forms with Chakra UI's Field
& Steps
components
✅ Adding form validation using Zod & React Hook Form
✅ Managing form state efficiently across multiple steps
✅ Implementing URL-based navigation (useSearchParams
) to persist form steps
- Overview of what we’ll build
- Why Next.js, React Hook Form, and Chakra UI?
- Installing Chakra UI v3 in a Next.js (App Router) project
- Setting up the Chakra UI provider
- Creating input fields with Chakra UI
- Structuring reusable form components
- Setting up validation schemas with Zod
- Connecting Zod to React Hook Form
- Displaying error messages with Chakra UI
- Implementing the step-by-step form navigation
- Styling and structuring steps dynamically
- Using the
Steps.PrevTrigger
component
- Implementing
useSearchParams
for step tracking - Updating the URL dynamically with
useRouter().push()
- Making the form refresh-proof & shareable
- Next.js 13+ (App Router)
- React Hook Form (Form handling)
- Chakra UI (UI styling & accessibility)
- Zod (Schema validation)
- useSearchParams & useRouter (Next.js navigation)
To follow along, clone this repo and install dependencies:
git clone https://github.com/estheragbaje/Multi-step-Onboarding-Form
cd onboarding-form
npm install
Run the project:
npm run dev
💡 Follow for more tutorials
📩 Twitter: @_estheradebayo
📺 YouTube: Esther
🚀 If you found this tutorial helpful, give it a ⭐ on GitHub and subscribe on YouTube!