Import Apex Methods

Use default import syntax in JavaScript to import an Apex method via the @salesforce/apex scoped packages.

  • apexMethodName—A symbol that identifies the Apex method.
  • apexMethodReference—The name of the Apex method to import.
  • classname—The name of the Apex class.
  • namespace—If the class is in the same namespace as the component, don’t specify a namespace. If the class is in a managed package, specify the namespace of the managed package.

When an Apex class name changes outside of the JavaScript source file, the class name is automatically updated in the JavaScript source file. Method and argument name changes aren’t updated in the JavaScript source file.

To call an Apex method, a Lightning web component can:

See Also