- Built on ECMAScript 6 and compatible with ECMAScript 5
- Asynchronous calls return ECMAScript 6 promises
- Support for modern developer workflows
- Modular architecture. Includes OAuth and DataService modules.
Built on ECMAScript 6
Here is a simple example showing how ForceJS 2 can be used in an ECMAScript 6 application to authenticate with Salesforce using OAuth and retrieve a list of contacts:
Compatible with ECMAScript 5
ForceJS 2 can also be used in plain ECMAScript 5 applications using AMD or CommonJS module loaders, or globally using the force.OAuth and force.DataService variables. This is achieved using a single code base by transpiling the ECMAScript 6 source code into an ECMAScript 5 compatible version using the Universal Module Definition (UMD) format.
Here is a simple example showing how ForceJS 2 can be used in an ECMAScript 5 application to authenticate with Salesforce using OAuth and retrieve a list of contacts:
ForceJS is built on a modular architecture. It currently includes two modules:
- forcejs/oauth: A module that makes it easy to authenticate with Salesforce using the OAuth User Agent workflow
- forcejs/data-service: A module that makes it easy to access data through the Salesforce APIs
forcejs/oauth and forcejs/data-service are typically used together in an application, but you can use them separately. For example, you could use forcejs/oauth by itself if all you need is a Salesforce access token (Lightning Out use cases). Similarly, you could use forcejs/data-service by itself if you already have an access token, and all you need is a library to access the Salesforce APIs.
Getting Started and API Reference
ForceJS is easy to use. To get started, try the Quick Starts available in repository’s readme file where the API reference also lives.