Skip to main content
Loading...

Inheritance in Aura

Abstract illustration of Aura BaseComponent inheritance with child components

Background

Aura supports component inheritance. Mark a component extensible="true" and others can extend it—so shared logic lives in one place.

A BaseComponent built on that idea became a reusable asset across Aura projects: callouts, spinners, errors, navigation, and more, with ongoing improvements over time.

Problem statement

  • Most components need the same basics: Aura-enabled Apex, loading state, error handling, navigation
  • Typos in controller/helper JavaScript are costly to debug
  • Lightning Out from Classic breaks events that work in LEX
  • Branding and cross-cutting behavior should apply consistently

Solution

Extend a generic base component that owns shared helpers and adapts Classic vs Lightning behavior.

Helpers include:

  • startWaiting / stopWaiting – spinner around async work
  • doCallout – Aura-enabled method with parameters and callback
  • navigateToRecord – record navigation (LEX and Classic)
  • handleErrors – normalize errors and show toasts
  • getAllUrlParams – parse URL parameters
  • doShowToast – toast helper for both experiences
  • doCloseModel – close a modal via the overlay library
  • myLog – centralized logging you can prefix or disable in one place
  • doRefresh – force:refreshView in LEX; page reload in Classic
  • doNewModel – open a modal for a component and attributes
  • doNavigateToObjectHome – sObject home (LEX)
  • doShowNotif – notification library (toast in Classic)
  • doNavigateToCommunityHome – community home
  • closeAllToasts – dismiss sticky toasts
  • createRecord – force:createRecord
  • closeFocusedTab / consoleOpenTab – console helpers

Examples

Extending the base component:

Extending BaseComponent in a custom Aura component

Calling base helpers from a child controller:

Calling BaseComponent helpers from a controller

Calling from a child helper (helper or this):

Calling BaseComponent helpers from a helper

Resources

  • Lightning: BaseComponent

Pre-deployment steps

  • Back up the target org; merge carefully if resources already exist.
  • Install or remove any documented dependencies (such as Dynamic Code Execution) as needed.

Deployment steps

Source: BaseComponent

Post-deployment steps

Deploy, extend BaseComponent from your custom components, and call the shared helpers as shown above.