Skip to main content
새로운 커뮤니티 대화를 Slack으로 이전함에 따라 온라인 Trailblazer Community는 2026년 10월 30일부터 읽기 전용으로 전환됩니다. FAQ를 읽어보십시오.

Create a Server-side Apex Controller Class

Note

This module is intended for Admins who support legacy Aura components. Lightning Web Components is the preferred way to build UI with Salesforce. Head over to the Migrate from Aura to Lightning Web Components trail to learn how to use LWC and comply with current web standards.

Salesforce Lightning Design System (SLDS) now has two versions. If you use Aura design tokens to style your Aura components, you’re working in the original Salesforce Lightning Design System, SLDS 1.

Salesforce Lightning Design System 2 (SLDS 2) was introduced in Spring ‘25. SLDS 2 is built with a new CSS framework that separates the structure from the visual design using styling hooks.

To switch to SLDS 2 and receive all of the benefits it offers, upgrade your Aura components to Lightning web components or Lightning base components and use styling hooks. To learn more, read Replace Design Tokens with Styling Hooks in the Aura developer guide. To learn more uplifting your code to SLDS 2, read Transitioning to SLDS 2 on the SLDS 2 website.

Introduction

The Lightning Component framework is a UI framework for developing dynamic web apps for mobile and desktop devices.

In this Quick Start, you'll create a simple Lightning Component that renders a list of Contacts from your org. You'll start by creating an Apex controller class, then create a Lightning Component and an event handler and finally render the list of Contacts in the component.

Follow Along with Trail Together

Want to follow along with an expert as you work through this step? Take a look at this video, part of the Trail Together series.

Build an Apex Controller

Create a class to access data from Contacts.

  1. In your Trailhead Playground, click Setup and select Setup.
  2. In the Quick Find box, search for and select Web Console.
  3. For Enable Developer Console, set it to Active.
  4. Refresh the page.
  5. Click the setup gear Setup and select Developer Console.
  6. Select File | New | Apex Class.
  7. For the class name, enter MyContactListController and then click OK.
  8. In the body of the class (i.e. between the {} braces), enter the following code Tip: You can copy and paste any code snippet from Trailhead by clicking Copy in the top right corner.
    @AuraEnabled
    public static List<Contact> getContacts(Id recordId) {
       return [SELECT Id, FirstName, LastName, Email, Phone FROM Contact WHERE AccountId = :recordId];
    }
    Apex methods designated @AuraEnabled are able to be called from a Lightning component.
  1. Select File | Save.
Salesforce 도움말에서 Trailhead 피드백을 공유하세요.

Trailhead에 관한 여러분의 의견에 귀 기울이겠습니다. 이제 Salesforce 도움말 사이트에서 언제든지 새로운 피드백 양식을 작성할 수 있습니다.

자세히 알아보기 의견 공유하기