Newer Version Available

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

Apex Class Considerations for Packages

Keep these considerations in mind when you develop Apex classes for packages.

Test Coverage

Any Apex that is included as part of your definition bundle must have at least 75% cumulative test coverage. When you upload your package to AppExchange, all tests are run to ensure that they run without errors. The tests are also run when the package is installed.

Grant User Access for Apex Classes

An authenticated or guest user can access an @AuraEnabled Apex method only when the user’s profile or an assigned permission set allows access to the Apex class.

  • To enable access to a public Apex controller that’s part of a managed package, a subscriber org must use a permission set. You can’t enable access to a public Apex controller from a managed package using a user profile.
  • To enable access to a global Apex controller that’s part of a managed package, a subscriber org can use a permission set or a user profile.

Apex Class Usage in Subscriber Orgs

Only methods marked with the global access modifier are accessible by Aura components from outside the managed package’s namespace. Methods marked with the public access modifier are accessible only to Aura components included in the managed package’s namespace.

If you declare an Apex method as global, you must also declare the Apex class that contains it as global.

An Aura component outside the package can access a public Apex method installed from a non-namespaced unlocked package. The Aura component can be installed from another package or created in the org. For accessing Apex methods, a non-namespaced unlocked package is treated the same as an unmanaged package.