Newer Version Available

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

Apex Server-Side Controller Overview

Create a server-side controller in Apex and use the @AuraEnabled annotation to enable client- and server-side access to the controller method.
Only methods that you have explicitly annotated with @AuraEnabled are exposed.

Don't store component state in your controller. Store it in a component's attribute instead.

Tip

This Apex controller contains a serverEcho action that prepends a string to the value passed in.

In addition to using the @AuraEnabled annotation, your Apex controller must follow these requirements.
  • Methods must be static and marked public or global. Non-static methods are not supported.
  • If a method returns an object, instance methods that retrieve the value of the object’s instance field must be public.

For more information, see Understanding Classes in the Apex Code Developer's Guide.