Open Source & Contributing
FormCN is community-driven. We'd love your help to make form building easier for everyone.
Getting Started
1. Setup the Project
FormCN is a monorepo managed by Turborepo.
- Fork & Clone:
git clone https://github.com/YOUR_USERNAME/formcn.git cd formcn - Install Dependencies:
pnpm install - Run Development Server:
This starts the web app atpnpm devhttp://localhost:3000.
Project Structure
apps/web: The main Next.js application containing the visual builder, documentation, and the registry source.apps/web/src/registry/default: The core of the registry.templates/: Definition files for form templates (e.g.,login.ts,onboarding-wizard.ts).lib/form-generator.ts: The logic that generates code from templates.ui/: Reusable UI components used within templates.
Common Tasks
Adding a New Template
Want to add a new form template? Follow these steps:
-
Create the Template Definition: Create a new file in
apps/web/src/registry/default/templates/(e.g.,booking-form.ts). Define the schema, fields, and steps using theFormTemplateinterface. -
Export the Template: Add your template to
apps/web/src/registry/default/templates/index.ts. -
Generate the Component: You need to create a static
.tsxversion of your form for the registry. You can use the visual builder locally to create it, or manually write it following the patterns in*-form.tsxfiles. Save it asapps/web/src/registry/default/templates/booking-form.tsx. -
Register the Component: Add an entry to
apps/web/registry.jsonunderitems.{ "name": "booking-form", "type": "registry:block", "files": [{ "path": "src/registry/default/templates/booking-form.tsx", ... }], ... } -
Build the Registry: Run the build script to update the public API files.
pnpm --filter web registry:build
Improving the Generator
If you want to improve the code generation logic (e.g., better validation support, new UI frameworks):
- Edit
apps/web/src/registry/default/lib/form-generator.ts. - Test your changes by running the visual builder and checking the "Code" tab.
- Run
pnpm --filter web registry:buildto update the generator artifacts.
Submitting Changes
- Create a branch for your feature (
git checkout -b feature/amazing-form). - Commit your changes.
- Push to your fork and submit a Pull Request.
We appreciate all contributions!