Newer Version Available

This content describes an older version of this product. View Latest

What Is the Lightning Component Framework?

The Lightning Component framework is a UI framework for developing dynamic web apps for mobile and desktop devices. You can build single-page applications engineered for growth.

The framework supports partitioned, multi-tier component development that bridges the client and server. It uses JavaScript on the client side and Apex on the server side.

The benefits include an out-of-the-box set of components and interfaces, event-driven architecture, and a framework optimized for performance.

Components

Components are the self-contained and reusable units of an app, which represent a reusable section of the UI. They can range in granularity from a single line of text to an entire app.

The framework includes a set of prebuilt components. For example, components that come with the Lightning Design System styling are available in the lightning namespace and are known as the base Lightning components. You can assemble and configure the components to form new components in an app. Components are rendered to produce HTML DOM elements within the browser.

A component can contain other components, along with HTML, CSS, JavaScript, Apex controllers, or any other web-enabled code, which enables you to build apps with sophisticated UIs.

The details of a component’s implementation are encapsulated. Encapsulation allows the consumer of a component to focus on building an app, while the component author can continue to innovate and make changes without breaking consumers’ apps. You configure components by setting the named attributes that they expose in their definition. Components interact with their environment by listening to or publishing events.

Events

Many languages and frameworks use event-driven programming, such as JavaScript and Java Swing. Handlers that you write respond to interface events as they occur.

A component registers that it might fire an event in its markup. Events are fired from JavaScript controller actions that are typically triggered by a user interacting with the user interface.

The framework has two types of events.

  • Component events are handled by the component itself or a component that instantiates or contains the component.
  • Application events are handled by all components that are listening to the event. These events are essentially a traditional publish-subscribe model.

Interfaces

Object-oriented languages, such as Java, support the concept of an interface that defines a set of method signatures. A class that implements the interface provides the method implementations. An interface in Java can’t be instantiated directly, but a class that implements the interface can. Similarly, the Lightning Component framework supports the concept of interfaces that define a component’s shape by defining its attributes.

Open Source Aura Framework

The Lightning Component framework is built on the open source Aura framework. The Aura framework enables you to build apps independent of your data in Salesforce.

The Aura framework is available at https://github.com/forcedotcom/aura. The open source Aura framework has features and components that aren’t yet available in the Lightning Component framework. We’re working to surface more of these features and components for Salesforce developers.