Interacting with Force.com through a React/Node.js application

31
Interacting with Force.com through a React/Node.js application Philippe Ozil Developer Evangelist @PhilippeOzil [email protected]

Transcript of Interacting with Force.com through a React/Node.js application

Page 1: Interacting with Force.com through a React/Node.js application

Interacting with Force.com through a React/Node.js applicationPhilippe OzilDeveloper Evangelist@[email protected]

Page 2: Interacting with Force.com through a React/Node.js application

Forward-Looking StatementsStatement under the Private Securities Litigation Reform Act of 1995:

This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services.

The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of any litigation, risks associated with completed and any possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site.

Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.

Page 3: Interacting with Force.com through a React/Node.js application

Agenda

Motivation & Goals

Demo

Project Architecture

React Frontend

Node.js Backend

Heroku Deployment

Closing Words

Page 4: Interacting with Force.com through a React/Node.js application

Motivation & Goals

Original intent• Learn React• Drive a React app with Force.com

ObstacleLack of documentation for full stack integration

Goals• Detail frontend & backend implementation• Cover common use cases

Page 6: Interacting with Force.com through a React/Node.js application

Project Architecture

Page 7: Interacting with Force.com through a React/Node.js application

Architecture Constraints

Typical web app

Frontend + backend

Force.com authenticationOAuth 2.0 + Force.com Connected Application

Keep app in the CloudHeroku hosting

Page 8: Interacting with Force.com through a React/Node.js application

Architecture Overview

Frontend Force.comBackend OAuth 2.0

REST

REST

Page 9: Interacting with Force.com through a React/Node.js application

React Frontend

Page 10: Interacting with Force.com through a React/Node.js application

Quick React Overview

Open source JS library created by Facebook

Popular alternative to AngularJS

React Fey concepts: ComponentState Property

Child componentState Property

Callback functionVariable

Page 11: Interacting with Force.com through a React/Node.js application

Quick React Overview (Continued)

JSX – JS XML preprocessor

Page 12: Interacting with Force.com through a React/Node.js application

React Application

React App

Nav bar

Query form

Query result

Login panel

Page 13: Interacting with Force.com through a React/Node.js application

React Code Example – App component

Page 14: Interacting with Force.com through a React/Node.js application

React Code Example – App component

Page 15: Interacting with Force.com through a React/Node.js application

React Code Example – App component

Page 16: Interacting with Force.com through a React/Node.js application

Backend Interactions

React App Node App

/auth/whoami

/query

Nav bar

Query formQuery result

React component

/auth/login

/auth/logout

Login panel

HTTP Endpoint

Navigates to

REST call

Navigates to

REST call

Page 17: Interacting with Force.com through a React/Node.js application

Node.js backend

Page 18: Interacting with Force.com through a React/Node.js application

Quick Node.js Overview

Open source JS runtime environment• Multi-platform• Event-driven• Asynchronous I/O• Wide range of modules/applications

Page 19: Interacting with Force.com through a React/Node.js application

Node Application

Node App

/auth/whoami

/query

/auth/logout

/auth/login /auth/callback

HTTP EndpointNode module

salesforce-node-clientauth

data

Page 20: Interacting with Force.com through a React/Node.js application

Node Interactions

Node App

/auth/whoami

/query

/auth/logout

/auth/login

/auth/callback

OAuth2

Data

Force.com serviceHTTP EndpointNode module

salesforce-node-client

auth

data

12

34

56

Page 21: Interacting with Force.com through a React/Node.js application

Node Code Example - Authentication

12 3

45

6

Page 22: Interacting with Force.com through a React/Node.js application

Heroku Deployment

Page 23: Interacting with Force.com through a React/Node.js application

Quick Heroku Overview

Company part of Salesforce

Cloud PaaS

• Runtimes• Databases• Build tools

Page 24: Interacting with Force.com through a React/Node.js application

Heroku Deployment

1. Push code to GitHub

Page 25: Interacting with Force.com through a React/Node.js application

Heroku Deployment

1. Push code to GitHub

2. Set Connected App & OAuth settings

Page 26: Interacting with Force.com through a React/Node.js application

Heroku Deployment

1. Push code to GitHub

2. Set Connected App & OAuth settings

3. Connect Heroku with GitHub

Page 27: Interacting with Force.com through a React/Node.js application

Heroku Deployment

1. Push code to GitHub

2. Set Connected App & OAuth settings

3. Connect Heroku with GitHub

4. Setup Heroku deploy

Page 28: Interacting with Force.com through a React/Node.js application

Closing word

Page 29: Interacting with Force.com through a React/Node.js application

Conclusion

• From development to deployment

• Low code volume

• JS build environment setup = pain

• Heroku deployment = piece of cake

• Try out & fork this project!

Page 30: Interacting with Force.com through a React/Node.js application

Resources

Sample Node/React application github.com/pozil/salesforce-react-integration

Reusable Salesforce Node client github.com/pozil/salesforce-node-client

Page 31: Interacting with Force.com through a React/Node.js application

Thank Y u