Aura -> LWC is similar to Visualforce -> LWC but easier because the component model is similar.
Reasons to migrate:
- Performance — LWC is faster (native rendering vs custom engine).
- Modern tooling — LWC works with VS Code / Jest / ESLint cleanly.
- Skill transfer — LWC is closer to React/Vue/Angular paradigms.
- Future investment — Salesforce is investing in LWC; Aura is in maintenance mode.
Mapping Aura concepts to LWC:
| Aura | LWC | |---|---| | <aura:component> | <template> + JS class | | <aura:attribute name="x" type="String"/> | @api x; (public) or x; (private) | | <aura:handler event="aura:doneRendering"> | renderedCallback() | | <aura:method> | @api decorated method | | Server-side: $A.callServerMethod | import myMethod from '@salesforce/apex/...' | | Aura events | CustomEvent | | aura:if | if:true={x} | | aura:iteration | for:each={items} | | Locker | Lightning Web Security (newer, less restrictive) |
Migration steps per component:
- Inventory — list all Aura components. Setup -> Lightning Components.
- Categorise — simple display, interactive, server-heavy, custom JS.
- Plan dependency order — child components first, then parents.
- Rewrite — for each component:
- Convert
.cmpmarkup to.htmltemplate (with directive renaming). - Convert controller.js / helper.js to a single
.jsclass. - Convert events to CustomEvents.
- Replace
$A.enqueueActionwith imperative or@wireApex calls. - Move attributes to
@apiproperties.
- Test thoroughly — Aura interop with LWC has subtle differences; test in real Lightning pages.
- Replace usage — find every place the Aura component was used; replace with the LWC equivalent.
- Deprecate / delete the Aura component.
Coexistence strategy — Aura and LWC can interoperate on the same page during migration. An Aura parent can host LWC children; LWC can dispatch events that Aura handles. Migration doesn't have to be all-or-nothing.
Common gotchas:
- Aura events are different — Aura's APPLICATION and COMPONENT events have richer routing than CustomEvent. Some patterns need rearchitecting (e.g., use Lightning Message Service for cross-tree communication).
- Attribute types — Aura supports more types; LWC's
@apionly supports primitives, arrays, plain objects. - Locker vs LWS — LWS is more permissive but stricter on certain patterns. Test with LWS enabled.
- Two-way binding in Aura (
{!v.x}) doesn't exist in LWC — explicit setter or event needed.
Tooling:
- VS Code Salesforce extensions edit both Aura and LWC.
- Jest for LWC unit tests.
- The migration is an opportunity to improve test coverage — Aura tests are notoriously hard.
A typical migration: 1 senior LWC dev migrates 5-10 components per week, depending on complexity. A 200-component org takes 6-12 months.
