Record pages are different from app pages in a key way: they have the context of a record. To make your components display content that is based on the current record, use a combination of an interface and an attribute.
Useful for components invoked in a context associated with a specific record, such as record page components or custom object actions. Add this interface if you want your component to receive the ID of the currently displaying record.
<aura:attribute name="recordId" type="String" />
Don’t expose the recordId attribute to the Lightning App Builder—don’t put it in the component’s design resource. You don’t want admins supplying a record ID.
The recordId attribute is set only when you place or invoke the component in a context of a record. For example, when you place the component on a record page, or invoke it as an action from a record page or object home. In all other cases, such as when you create this component programmatically inside another component, recordId isn’t set, and your component shouldn’t depend on it.
Useful for record page components. Implement this interface if your component needs to know the API name of the object of the currently displaying record.
<aura:attribute name="sObjectName" type="String" />
The sObjectName attribute is set only when you place or invoke the component in a context of a record. For example, when you place the component on a record page, or invoke it as an action from a record page or object home. In all other cases, such as when you create this component programmatically inside another component, sObjectName isn’t set, and your component shouldn’t depend on it.