ForceServer: A Local Server to Streamline Salesforce OAuth and REST Development

Salesforce provides a REST API that makes it easy to access and manipulate Salesforce data from any application.

To start using Salesforce OAuth and the REST APIs, you need to add a few components to your development environment:

  • A Proxy Server to avoid cross-domain policy issues when invoking Salesforce REST services. (The Chatter API supports CORS, but other APIs don’t yet)
  • A Local Web Server to (1) serve the OAuth callback URL defined in your Connected App, and (2) serve the whole app during development and avoid cross-domain policy issues when loading files (for example, templates) from the local file system.

There are of course existing proxy servers and local web servers, but what’s often lacking is a simple and integrated developer experience.


To experiment with a streamlined developer experience, I put together ForceServer, a simple development server that combines a Proxy Server built for the Salesforce REST APIs, and a Local Web Server to serve your app during development.

To install ForceServer, make sure Node.js is installed on your system, open a command prompt and type:

npm install -g force-server

or (Mac):

sudo npm install -g force-server

Build your First Salesforce REST App in 2 Minutes

Now that the server is installed on your system, let’s put the developer experience to the test by creating an application that displays the proverbial list of Salesforce contacts:

  1. Create a file named index.html anywhere on you file system:
    <ul id="list"></ul>
    <script src=""></script>
    force.login(function() {
        force.query('select id, Name from contact LIMIT 50', function (response) {
            var str = '';
            for (var i = 0; i < response.records.length; i++) {
                str += '<li>' + response.records[i].Name + '</li>';
            document.getElementById('list').innerHTML = str;
    In a real-lfe app, you should host the force.js file on your own server or development machine.
  2. Start ForceServer in the directory where you created index.html:

    This command will start the server on port 8200, and automatically load your app (http://localhost:8200) in a browser window. You’ll see the Salesforce login window (make sure you enable the popup window), and the list of contacts will appear after you log in. If you don’t have a free Salesforce Developer Edition to log in to, you can create one here.

    You can change the port number and the web root. Type force-server --help for more info.

Code Highlights:

  • The sample application above uses the ForceJS library. ForceJS and ForceServer are built to work closely together and provide an integrated developer experience.
  • ForceJS uses a default connected app: No need to create a connected app to start development. You should however create your own connected app for production use.
  • ForceServer automatically serves the OAuth callback URL: No need to create a callback HTML page during development.

Transparently Running Hybrid Apps on Device and in the Browser

If you develop a hybrid application using the Mobile SDK, you often switch back and forth between running the app in the browser and on device: Developing in the browser is generally faster and easier to debug, but you still need to test device-specific features and check that everything runs as expected on the target platforms. The problem is that the configuration of OAuth and REST is different when running in the browser and on-device. Here is a summary of the key differences:

Browser Device
Proxy Yes No
OAuth Popup Plugin

ForceJS abstracts these differences and allows you to run your app in the browser and on device without code or configuration change.

Closing Comments

This is mostly an experiment at this point, and I’m planning to test it in workshops and hackathons to simplify the initial developer experience. I’m interested in hearing from you: what’s your setup when building applications using Salesforce OAuth and the REST APIs?

10 Responses to ForceServer: A Local Server to Streamline Salesforce OAuth and REST Development

  1. EL November 15, 2014 at 4:20 pm #

    This is a tremendous help and will help my productivity tremendously!

  2. istanbul travestileri November 18, 2014 at 5:23 am #

    Thanks for the info

  3. Rahat Khanna November 24, 2014 at 1:38 am #

    It provides a great abstract way to test Salesforce Hybrid App development and developing interactive UI for salesforce platform out of the visual force space.

  4. kattie January 5, 2015 at 7:13 pm #

    This website based on mobile phone electronics and you can see all companies of mobile price specifacation Etc Click Here For More Information

  5. futbol çorapları November 17, 2015 at 8:45 am #

    качество, надежность, экономичность и связанные работы выполняются imalattan.rofesyonek команду

  6. çelik raf November 19, 2015 at 1:46 am #

    xorosaya rabota

  7. sohbet odalari December 8, 2015 at 5:09 pm #

    very blog nice admin

  8. CIIT Noida April 21, 2018 at 3:00 am #

    appreciate you sharing this blog.Really looking forward to read more. Much obliged.

    Hadoop Training Institute in Noida

  9. CIIT Noida April 25, 2018 at 2:52 am #

    I learning about a lot of great information for this weblog. We share it valuable information

    Best B.Tech College in Noida

  10. yuvaraj singh February 22, 2021 at 3:46 am #

    Thanks for sharing this.,
    Leanpitch provides online training in CSPO during this lockdown period everyone can use it wisely.
    Join Leanpitch 2 Days CSPO Certification Workshop in different cities.

    CSPO certification

    CSPO certification online

    Product owner certification

    Certified scrum product owner

    CSPO certification cost




Leave a Reply