I have existing code which contains upto 20 hard coded messages(info, error etc.) inside my lightning JS controller.

I am confused whether to use custom labels or custom settings as part of code improvement.

I don't need any language translations in my project.

Can someone help me to provide the best practice to be followed in this situation?

2 Answers 2


If you have many hard coded messages at your component then better to use Custom Settings, as you can cache those messages. All the entries are stored as records as opposed to individual components like custom label.

Custom Labels are good if you have translations at your org and trying to remove hard coded values. Every label will be treated as separate components.

Accessing the Custom Label requires less coding and can be done on client side itself as follows:


Whereas to use Custom setting you need both client and server side coding. Refer How to Access a Hierarchy Custom Setting from Lightning Component.


I think the best thing to do is to created custom labels because custom settings needs to be queried.

  • While it is true that custom settings can be queried, you don't need to query for them. The getInstance() or getAll() methods (inside an @auraenabled apex method) would work.
    – Derek F
    Aug 10, 2018 at 12:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .