Lightning Interface In Aura Components And Everything You Need To Know About Them

Eveyrhting you need to know about Interfaces in Aura Components

Lightning Interface In Aura Components And Everything You Need To Know About Them

When we try to create an Aura Component we will be given the option to include interfaces, by adding interfaces we are trying to make the components accessible at different places in Lightning Experience.

Mostly used Lightning Interface

  • force:appHostable
  • flexipage:availableForAllPageTypes
  • flexipage:availableForRecordHome
  • force:lightningQuickAction
  • forceCommunity:availableForAllPageTypes
  1. force:appHostable When we try to create a component, by default they are lifeless and what I mean by that is, we cannot see the output of at the component, as is. We need to either embed the component in a Lightning App or record page or we need to create a tab (just like how we create a tab for Visualforce pages) or we need to plug the component in the Quick Action or etc.
    In case we need to create a tab for the component force:appHostable is the interface that we need to add to the component. Once the interface is added the process of creating a tab is very much similar to that of creating a tab to a Visualforce page.
  2. flexipage:availableForAllPageTypes Let me give you a scenario when we would need this Interface, In case we need to create an Aura component and embed that into Lightning pages using App Builder, that’s when we pad the component with this Interface.
  3. flexipage:availableForRecordHome In case you need a Lightning component that has to be embedded in a record detail page that’s when we use this Interface. In case we don’t apply this interface, though the component has the business logic in it, the component fails to appear in the App Builder when we edit the page.
  4. force:lightningQuickAction When we want a component to be plugged in a Quick Action that’s when we use this component. We will face a few bottle necks when we work on migration projects, especially when it has JavaScript buttons. That’s when Quick Actions come to our rescue. We use Quick Actions to replace JavaScript Buttons.
  5. forceCommunity:availableForAllPageTypes When we need components to be used in Communities either Customer or Partner that’s when we tend to use this interface.

Not only these there are lot of other interfaces that are at our disposal which we can use and make sure the development experience is seamless.

One such Interface is force:hasRecordId when a component implements this interface it will strip the Id from the URL and gives it back to us. We can assign the stripped Id to attributes and use it to our convenience.

Another most frequently used Interface is lightning:isUrlAddressable when our component has functionality which involves navigating the user from one component to another component or navigation from one component to record detail page or object home page or Knowledge Article page then this interfaces comes in handy.

Check the documentation to get a hang of all the Interfaces which are available. → Few other interfaces that we can make use of

Also, check out my previous post on → Difference between Implements and Extends