Sub topic 16
Migrate from Reactive Forms
This chapter assumes you can build a Reactive Forms form with FormGroup, FormControl, and Validators. It also assumes you know Angular signals (signal(), computed(), input(), output()) and have read the earlier chapters on form(), the [field] binding, validators, and submit().
Signal Forms is experimental in Angular 21. Treat everything here as a plan you re-check against the release notes of the version you use. Names such as Field and [field] may change.
Decide whether to migrate
Reactive Forms is not deprecated. It is stable, widely used, and fully supported. Migrating a working form gives you no new user-facing behavior. It is worth doing when one of these is true:
- You are starting a new form. Write it with Signal Forms from the start, if your team accepts an experimental API.
- A form is hard to maintain because you keep syncing
valueChangesinto signals by hand. - You are already rewriting the component, for example when moving it to a signal-based design.
Leave stable forms in production alone until the API leaves experimental status, unless you have a concrete reason. Migration is incremental: both systems can live in one application, and you choose the order.
Map the concepts
Most Reactive Forms ideas have a direct counterpart. The main change is where the data lives. In Reactive Forms, the control tree holds the value. In Signal Forms, your own signal model holds it, and form() builds a field tree on top.
| Reactive Forms | Signal Forms |
|---|---|
| `FormGroup` of `FormControl`s | A signal model plus `form(model, schema)` |
| `formControlName` or `[formControl]` | `[field]="myForm.email"` |
| `control.value` | `myForm.email().value()` or read the model directly |
| `control.setValue()` or `patchValue()` | `model.set()` or `model.update()` |
| `Validators.required`, `Validators.email` | `required(path.x)`, `email(path.x)` |
| A custom `ValidatorFn` | `validate(path.x, ctx => ...)` |
| A group-level validator for cross-field rules | `validate()` with `valueOf()` to read the other field |
| `control.disable()` | `disabled(path.x, ctx => ...)`, derived from state |
| `control.errors` (an object keyed by error name) | `field().errors()` (an array of objects with `kind`) |
| `markAllAsTouched()` then check `valid` | `submit(form, action)` |
| `FormArray` | An array in the model plus `applyEach` |
| `ControlValueAccessor` | A custom control that works with `[field]` |
| `valueChanges` subscription | `computed()` or `effect()` over the model |
Two differences cause most surprises.
First, disabled state is declarative. You do not call a method at the right moment. You write a rule that derives the state from other values, so it can never get out of sync.
Second, errors are a list of objects, not a record keyed by validator name. Template code such as control.errors?.['required'] becomes a loop over errors() or a check on the kind of each error.
Plan the migration
Work from the leaves of your application inward.
- Inventory. List each form, its validators, its async checks, its custom
ControlValueAccessorclasses, and any code that readsvalueChanges. - Pick a small form. A login or search form is a good first target. Avoid forms with many custom controls first.
- Define the model. Write an interface and a
signal()with initial values. Use''for empty text, notnull, so the types stay simple. - Port the rules. Move each validator into the schema function.
- Port the template. Replace
formControlNamewith[field]and thecontrol.errorschecks witherrors(). - Port tests. Tests that set values through the DOM keep working. Tests that call
control.setValue()change tomodel.set().
A side-by-side example
Here is a Reactive Forms login form.
import { Component, inject } from '@angular/core';
import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms';
@Component({
selector: 'app-login-old',
imports: [ReactiveFormsModule],
template: `
<form [formGroup]="form" (ngSubmit)="onSubmit()">
<input type="email" formControlName="email" />
@if (form.controls.email.touched && form.controls.email.errors?.['required']) {
<p class="error">Email is required</p>
}
<input type="password" formControlName="password" />
<button type="submit" [disabled]="form.invalid">Log in</button>
</form>
`,
})
export class LoginOldComponent {
private readonly fb = inject(FormBuilder);
protected readonly form = this.fb.nonNullable.group({
email: ['', [Validators.required, Validators.email]],
password: ['', Validators.required],
});
protected onSubmit() {
if (this.form.invalid) return;
console.log(this.form.getRawValue());
}
}The Signal Forms version keeps the same behavior.
import { Component, signal } from '@angular/core';
import { form, Field, required, email, submit } from '@angular/forms/signals';
@Component({
selector: 'app-login-new',
imports: [Field],
template: `
<form (submit)="onSubmit($event)">
<input type="email" [field]="loginForm.email" />
@if (loginForm.email().touched() && loginForm.email().invalid()) {
@for (error of loginForm.email().errors(); track error.kind) {
<p class="error">{{ error.message }}</p>
}
}
<input type="password" [field]="loginForm.password" />
<button type="submit" [disabled]="loginForm().invalid()">Log in</button>
</form>
`,
})
export class LoginNewComponent {
private readonly model = signal({ email: '', password: '' });
protected readonly loginForm = form(this.model, (path) => {
required(path.email, { message: 'Email is required' });
email(path.email, { message: 'Enter a valid email address' });
required(path.password, { message: 'Password is required' });
});
protected onSubmit(event: Event) {
event.preventDefault();
submit(this.loginForm, async () => {
console.log(this.model());
});
}
}Note what changed. The validators moved out of the model definition into one schema function. The error messages now live next to the rules instead of in template @if branches. The component no longer needs FormBuilder or any forms module.
Run both systems together
Large applications cannot switch in one release. The safest bridge uses only ordinary Angular inputs and outputs. A migrated child component owns a Signal Form and talks to its Reactive Forms parent through its public interface.
import { Component, input, linkedSignal, output } from '@angular/core';
import { form, Field, required, email, submit } from '@angular/forms/signals';
export interface Contact {
name: string;
email: string;
}
@Component({
selector: 'app-contact-editor',
imports: [Field],
template: `
<form (submit)="onSubmit($event)">
<label>Name <input [field]="contactForm.name" /></label>
<label>Email <input type="email" [field]="contactForm.email" /></label>
<button type="submit" [disabled]="contactForm().invalid()">Save</button>
</form>
`,
})
export class ContactEditorComponent {
readonly contact = input.required<Contact>();
readonly saved = output<Contact>();
// Resets to the parent's value whenever the input changes.
private readonly model = linkedSignal(() => ({ ...this.contact() }));
protected readonly contactForm = form(this.model, (path) => {
required(path.name, { message: 'Name is required' });
required(path.email, { message: 'Email is required' });
email(path.email, { message: 'Enter a valid email address' });
});
protected onSubmit(event: Event) {
event.preventDefault();
submit(this.contactForm, async () => {
this.saved.emit(this.model());
});
}
}The parent can stay on Reactive Forms. It passes contact() in and writes the result back with (saved)="parentForm.controls.contact.setValue($event)". When the parent is migrated later, you change only the parent.
Angular 21 also ships experimental interop helpers that let you place an existing FormControl inside a signal form. Check the current Angular documentation for their exact names and limits before relying on them. The input and output bridge above works with stable APIs only, so it is the safer default.
Port custom controls and arrays
ControlValueAccessor. The old interface (writeValue,registerOnChange,registerOnTouched) is replaced by a custom control that Signal Forms binds directly. See the earlier chapter on custom controls. Until you port a control, keep it inside forms that are still Reactive.FormArray. Use an array in the model andapplyEachin the schema. Adding or removing a row becomesmodel.update()on the array.valueChanges. Most uses become acomputed()over the model. Useeffect()only for real side effects, such as saving a draft.- Async validators. Move them to the async validation API from the earlier chapter. Check how they handle debouncing in your Angular version before you replace a working
asyncValidatorssetup.
Common errors during migration
- Null in the model. Reactive Forms controls often start as
null. Signal Forms works best when every field has a plain starting value that matches the input type. - Checking
errors().required.errors()is an array. Comparekindvalues instead. - Mutating the model object in place. Replace objects with
set()orupdate()so signals notice the change. - Forgetting the import. Without
Fieldinimports, the[field]binding does not work. - Assuming the API is frozen. Keep form code in a few files so a later rename touches little.
Exercise
A Reactive Forms component has a group validator that checks that endDate is after startDate, and it calls form.controls.endDate.disable() when allDay is checked. Which Signal Forms functions replace these two pieces, and how does the second one differ from the original in when it runs?
Show answer
Replace the group validator with validate(path.endDate, ({ value, valueOf }) => ...), reading startDate through valueOf(path.startDate) and returning null when valid or an error object with a kind and message when not. Replace the disable() call with disabled(path.endDate, ({ valueOf }) => valueOf(path.allDay)). The original runs once, at the moment you call it, so you must remember to call enable() again. The disabled() rule is derived from allDay, so it is re-evaluated whenever allDay changes and cannot get out of sync.