SlideShare a Scribd company logo
BACKBONE & REACT 
SEATTLE REACT MEETUP 
slides.formidablelabs.com 
/201411-react-backbone.html 
 |  
@ryan_roemer formidablelabs.com
BRIDGING THE OLD & NEW
SURVEY 
Who's familiar with Backbone? 
With React?
GOAL 
Craft a Backbone/React 
app: 
Lean and straightforward 
Efficient, performant in the browser 
Capable of server-side rendering
BACKBONE.JS
WHY BACKBONE.JS? 
Lean and mean 
Simple, powerful abstractions 
Models, Views, Routers 
REST friendly
BUT... 
Dependencies on jQuery, Underscore.js 
In practice, lots of DOM churn
FORMIDABLE LABS
BACKBONE.JS TESTING
LET'S WRITE SOME NOTES!
VANILLAJS (LOCALSTORAGE) 
(live) backbone-testing.com/notes/app/ 
github.com/ryan-roemer/backbone-testing/ 
tree/master/notes/app
COMMONJS (REST) 
Modern build - CommonJS, Webpack, 
Backbone, jQuery, Lodash 
github.com/formidablelabs/notes/ 
tree/master/alt/commonjs
BACKBONE.JS ABSTRACTIONS
MODELS 
Backbone.Model 
A contains, 
retrieves, and manipulates the data for 
your app. 
A note. 
Relies on $.ajax for REST transport. 

COLLECTIONS 
Backbone.Collection 
A is an 
ordered list of models. 
A list of notes. 
  
TEMPLATES 
A function that renders model / 
collection object data as HTML. 

VIEWS 
Backbone.View 
A mediates data, 
event and display logic. 
Display all notes, or a single note. 
Where most jQuery comes into play. 

ROUTERS 
Backbone.Router 
A routes client-side 
pages and mediates history. 
Route between all and single note 
views. 

CODE ORGANIZATION 
/ 
app.js config.js 
collections/notes.js 
models/note.js 
routers/router.js 
templates/ 
note-view.hbs note.hbs notes-item.hbs 
views/ 
note-nav.js note-view.js note.js 
notes-filter.js notes-item.js notes.js
BUNDLE SIZE 
Minified: 193 KB 
Gzipped: 63 KB
REACT
WHY REACT 
? 
Virtual DOM diffing / updating 
Server-side rendering 
Declarative, template-like UI components
BRINGING REACT TO NOTES 
github.com/FormidableLabs/ 
notes-react-backbone 
notes-react-exoskeleton 
- A basic port of Backbone.js views to React components. 
- The leaner version...
LET'S WRITE MORE NOTES! 
(live) formidablelabs.github.io/notes-react- 
exoskeleton/app.html 
github.com/FormidableLabs/notes-react- 
exoskeleton
REACT CLIENT-SIDE 
Switch Backbone.js views to React components 
Continue using Backbone.js models, collections, routers
PORTING NOTES 
Let React handle all the HTML 
No more templates / Handlebars 
Use BB models/collections as React props 
Update React components on Backbone.js events
EXOSKELETON 
Backbone.js, without the 
dependencies. 
Get rid of jQuery and Underscore.js 
Need $.ajax replacement
CODE ORGANIZATION 
# Backbone! 
app.js 
collections/notes.js 
models/note.js 
routers/router.js 
# React! 
components/ 
note.jsx notes.jsx 
nav/base.jsx nav/note.jsx 
nav/notes.jsx 
page/base.jsx 
page/note.jsx page/note/edit.jsx 
page/note/view.jsx 
page/notes.jsx page/notes/item.jsx
BUNDLE SIZE 
Minified: 170 KB (vs 193 KB) 
Gzipped: 51 KB (vs 63 KB)
NOTES COMPONENT 
module.exports = React.createClass({ 
// ... 
render: function () { 
return ( 
<div> 
<NotesNav notes={this.props.notes} 
onUpdateFilter= 
{this.onUpdateFilter} /> 
<NotesPage notes={this.props.notes} 
filter={this.state.filter} /> 
</div> 
); 
} 
});
NOTE COMPONENT 
module.exports = React.createClass({ 
// ... 
render: function () { 
return ( 
<div> 
<NoteNav note={this.props.note} 
action={this.state.action} 
handleActionChange= 
{this.setAction} /> 
<NotePage note={this.props.note} 
action={this.state.action} /> 
</div> 
); 
} 
});
APP HTML 
var NO_SERVER_SIDE = true; 
<body> 
<div class="js-content"> 
<!-- No starting content --> 
</div> 
<script src="/app/js-dist/bundle.js"></script> 
</body>
REACT SERVER-SIDE 
Import Note, Notes components server-side with CommonJS 
+ Webpack 
Duplicate router logic on server 
Mirror pushState fragments with href links 
Check out react-router
APP HTML 
var NO_JS = true; 
<body> 
<div class="js-content"> 
{{{content}}} 
</div> 
<!-- No JavaScript --> 
</body>
BOOTSTRAPPED HTML 
Now let's tie it all together: 
Start with server-rendered HTML 
Bootstrap the SPA off that 
Client-side render from there...
AWESOME!
APP HTML TEMPLATE 
<body> 
<div class="js-content"> 
{{{content}}} 
</div> 
<script class="js-initial-data" 
type="application/json"> 
{{{initialData}}} 
</script> 
<script src="/app/js-dist/bundle.js"></script> 
</body>
CONCLUSION 
 Render and let React handle DOM diffing 
 Server-side rendering is easy 
 Leave jQuery behind
PARTING THOUGHTS 
Dataflow is... different 
Dive in more to the ecosystem: , Flux React router, etc.
RESOURCES 
todomvc.com/examples/react-backbone 
github.com/jhudson8/backbone-reaction 
github.com/clayallsopp/react.backbone 
github.com/magalhas/backbone-react-component
THANKS! 
slides.formidablelabs.com 
/201411-react-backbone.html 
 |  
@ryan_roemer formidablelabs.com

More Related Content

PDF
"Backbone React Flux" Артем Тритяк
PDF
Backbone & React Together Forever
PPTX
Organized web app development using backbone.js
PPTX
PDF
WordPress 2017 with VueJS and GraphQL
PPTX
PDF
Nuxt.js - Introduction
PPTX
SenchaCon 2016: Building Enterprise Ext JS Apps with Mavenized Sencha Cmd - F...
"Backbone React Flux" Артем Тритяк
Backbone & React Together Forever
Organized web app development using backbone.js
WordPress 2017 with VueJS and GraphQL
Nuxt.js - Introduction
SenchaCon 2016: Building Enterprise Ext JS Apps with Mavenized Sencha Cmd - F...

What's hot (20)

PDF
Sails.js Intro
PDF
Building a Single-Page App: Backbone, Node.js, and Beyond
KEY
New Perspectives on Performance
PDF
Case study: JBoss Developer Studio, an IDE for Web, Mobile and Cloud applicat...
PDF
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
PDF
Project development - preparing hell dish together – Oleksii Dashkevych
PPTX
Angular 1.5 Components
PDF
Using Magnolia in a Microservices Architecture
PDF
Deep dive into Vue.js
PPTX
Kickstart sencha extjs
PDF
AngularJS with RequireJS
PDF
Integrating Browserify with Sprockets
PDF
Evaluating and Choosing ZK Framework
PDF
The Evolution of Airbnb's Frontend
PPTX
PDF
Microservices with Spring Boot
PPTX
Revive- a Single page application framework
ODP
An Introduction to Vuejs
PDF
Pieter De Baets - An introduction to React Native
Sails.js Intro
Building a Single-Page App: Backbone, Node.js, and Beyond
New Perspectives on Performance
Case study: JBoss Developer Studio, an IDE for Web, Mobile and Cloud applicat...
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Project development - preparing hell dish together – Oleksii Dashkevych
Angular 1.5 Components
Using Magnolia in a Microservices Architecture
Deep dive into Vue.js
Kickstart sencha extjs
AngularJS with RequireJS
Integrating Browserify with Sprockets
Evaluating and Choosing ZK Framework
The Evolution of Airbnb's Frontend
Microservices with Spring Boot
Revive- a Single page application framework
An Introduction to Vuejs
Pieter De Baets - An introduction to React Native
Ad

Viewers also liked (20)

PDF
CascadiaJS 2014 - Making JavaScript Tests Fast, Easy & Friendly
PDF
JavaScript Architektur
PDF
Learn Frontend Testing
PDF
Node.js in Production
PDF
TDC São Paulo - React presentation
PPTX
Grokking TechTalk #16: F**k bad CSS
PDF
[2015/2016] Backbone JS
PPTX
Grokking TechTalk #16: Maybe functor in javascript
PDF
Breaking the Server-Client Divide with Node.js and React
PDF
Introduction to React Native & Redux
PDF
Arcus
PDF
1.openseminar
PPT
Get MEAN! Node.js and the MEAN stack
PDF
5.yobi를 활용한 개발자 협업 및 배포 프로세스
PDF
Developing and deploying applications with Spring Boot and Docker (@oakjug)
PPTX
Grokking TechTalk #16: React stack at lozi
PPTX
Microservices with Node.js and Apache Cassandra
PPTX
TDC2016SP - Trilha Frameworks JavaScript
PDF
네이버 오픈세미나 백엔드_아키텍쳐
PDF
Using ReactJS in AngularJS
CascadiaJS 2014 - Making JavaScript Tests Fast, Easy & Friendly
JavaScript Architektur
Learn Frontend Testing
Node.js in Production
TDC São Paulo - React presentation
Grokking TechTalk #16: F**k bad CSS
[2015/2016] Backbone JS
Grokking TechTalk #16: Maybe functor in javascript
Breaking the Server-Client Divide with Node.js and React
Introduction to React Native & Redux
Arcus
1.openseminar
Get MEAN! Node.js and the MEAN stack
5.yobi를 활용한 개발자 협업 및 배포 프로세스
Developing and deploying applications with Spring Boot and Docker (@oakjug)
Grokking TechTalk #16: React stack at lozi
Microservices with Node.js and Apache Cassandra
TDC2016SP - Trilha Frameworks JavaScript
네이버 오픈세미나 백엔드_아키텍쳐
Using ReactJS in AngularJS
Ad

Similar to Backbone.js with React Views - Server Rendering, Virtual DOM, and More! (20)

PPTX
Up and Running with ReactJS
KEY
Give Your JavaScript Apps Some Spine
PPTX
Painless Migrations from Backbone to React/Redux
PDF
JSLab. Алексей Волков. "React на практике"
PDF
An Overview of the React Ecosystem
PPTX
BackboneJS Training - Giving Backbone to your applications
PPT
Backbone.js
PDF
[DevDay 2017] ReactJS Hands on - Speaker: Binh Phan - Developer at mgm techno...
PDF
An Intense Overview of the React Ecosystem
PDF
Backbone JS for mobile apps
PPTX
One code Web, iOS, Android
PDF
Workshop 27: Isomorphic web apps with ReactJS
PPTX
React.js at Cortex
PPTX
Backbone the Good Parts
PDF
Server side rendering with React and Symfony
PDF
Learning React - I
PDF
Content-Driven Apps with React
PDF
Developing Backbonejs Applications Early Release Addy Osmani
PDF
Backbone.js
PDF
React Tech Salon
Up and Running with ReactJS
Give Your JavaScript Apps Some Spine
Painless Migrations from Backbone to React/Redux
JSLab. Алексей Волков. "React на практике"
An Overview of the React Ecosystem
BackboneJS Training - Giving Backbone to your applications
Backbone.js
[DevDay 2017] ReactJS Hands on - Speaker: Binh Phan - Developer at mgm techno...
An Intense Overview of the React Ecosystem
Backbone JS for mobile apps
One code Web, iOS, Android
Workshop 27: Isomorphic web apps with ReactJS
React.js at Cortex
Backbone the Good Parts
Server side rendering with React and Symfony
Learning React - I
Content-Driven Apps with React
Developing Backbonejs Applications Early Release Addy Osmani
Backbone.js
React Tech Salon

Recently uploaded (20)

PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
cuic standard and advanced reporting.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Modernizing your data center with Dell and AMD
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPT
Teaching material agriculture food technology
PDF
KodekX | Application Modernization Development
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
A Presentation on Artificial Intelligence
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Big Data Technologies - Introduction.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
cuic standard and advanced reporting.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
NewMind AI Monthly Chronicles - July 2025
CIFDAQ's Market Insight: SEC Turns Pro Crypto
MYSQL Presentation for SQL database connectivity
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Encapsulation_ Review paper, used for researhc scholars
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Modernizing your data center with Dell and AMD
Building Integrated photovoltaic BIPV_UPV.pdf
Teaching material agriculture food technology
KodekX | Application Modernization Development
Digital-Transformation-Roadmap-for-Companies.pptx
A Presentation on Artificial Intelligence
Mobile App Security Testing_ A Comprehensive Guide.pdf
The AUB Centre for AI in Media Proposal.docx
Big Data Technologies - Introduction.pptx

Backbone.js with React Views - Server Rendering, Virtual DOM, and More!

  • 1. BACKBONE & REACT SEATTLE REACT MEETUP slides.formidablelabs.com /201411-react-backbone.html  |  @ryan_roemer formidablelabs.com
  • 3. SURVEY Who's familiar with Backbone? With React?
  • 4. GOAL Craft a Backbone/React app: Lean and straightforward Efficient, performant in the browser Capable of server-side rendering
  • 6. WHY BACKBONE.JS? Lean and mean Simple, powerful abstractions Models, Views, Routers REST friendly
  • 7. BUT... Dependencies on jQuery, Underscore.js In practice, lots of DOM churn
  • 11. VANILLAJS (LOCALSTORAGE) (live) backbone-testing.com/notes/app/ github.com/ryan-roemer/backbone-testing/ tree/master/notes/app
  • 12. COMMONJS (REST) Modern build - CommonJS, Webpack, Backbone, jQuery, Lodash github.com/formidablelabs/notes/ tree/master/alt/commonjs
  • 14. MODELS Backbone.Model A contains, retrieves, and manipulates the data for your app. A note. Relies on $.ajax for REST transport. 
  • 15. COLLECTIONS Backbone.Collection A is an ordered list of models. A list of notes.   
  • 16. TEMPLATES A function that renders model / collection object data as HTML. 
  • 17. VIEWS Backbone.View A mediates data, event and display logic. Display all notes, or a single note. Where most jQuery comes into play. 
  • 18. ROUTERS Backbone.Router A routes client-side pages and mediates history. Route between all and single note views. 
  • 19. CODE ORGANIZATION / app.js config.js collections/notes.js models/note.js routers/router.js templates/ note-view.hbs note.hbs notes-item.hbs views/ note-nav.js note-view.js note.js notes-filter.js notes-item.js notes.js
  • 20. BUNDLE SIZE Minified: 193 KB Gzipped: 63 KB
  • 21. REACT
  • 22. WHY REACT ? Virtual DOM diffing / updating Server-side rendering Declarative, template-like UI components
  • 23. BRINGING REACT TO NOTES github.com/FormidableLabs/ notes-react-backbone notes-react-exoskeleton - A basic port of Backbone.js views to React components. - The leaner version...
  • 24. LET'S WRITE MORE NOTES! (live) formidablelabs.github.io/notes-react- exoskeleton/app.html github.com/FormidableLabs/notes-react- exoskeleton
  • 25. REACT CLIENT-SIDE Switch Backbone.js views to React components Continue using Backbone.js models, collections, routers
  • 26. PORTING NOTES Let React handle all the HTML No more templates / Handlebars Use BB models/collections as React props Update React components on Backbone.js events
  • 27. EXOSKELETON Backbone.js, without the dependencies. Get rid of jQuery and Underscore.js Need $.ajax replacement
  • 28. CODE ORGANIZATION # Backbone! app.js collections/notes.js models/note.js routers/router.js # React! components/ note.jsx notes.jsx nav/base.jsx nav/note.jsx nav/notes.jsx page/base.jsx page/note.jsx page/note/edit.jsx page/note/view.jsx page/notes.jsx page/notes/item.jsx
  • 29. BUNDLE SIZE Minified: 170 KB (vs 193 KB) Gzipped: 51 KB (vs 63 KB)
  • 30. NOTES COMPONENT module.exports = React.createClass({ // ... render: function () { return ( <div> <NotesNav notes={this.props.notes} onUpdateFilter= {this.onUpdateFilter} /> <NotesPage notes={this.props.notes} filter={this.state.filter} /> </div> ); } });
  • 31. NOTE COMPONENT module.exports = React.createClass({ // ... render: function () { return ( <div> <NoteNav note={this.props.note} action={this.state.action} handleActionChange= {this.setAction} /> <NotePage note={this.props.note} action={this.state.action} /> </div> ); } });
  • 32. APP HTML var NO_SERVER_SIDE = true; <body> <div class="js-content"> <!-- No starting content --> </div> <script src="/app/js-dist/bundle.js"></script> </body>
  • 33. REACT SERVER-SIDE Import Note, Notes components server-side with CommonJS + Webpack Duplicate router logic on server Mirror pushState fragments with href links Check out react-router
  • 34. APP HTML var NO_JS = true; <body> <div class="js-content"> {{{content}}} </div> <!-- No JavaScript --> </body>
  • 35. BOOTSTRAPPED HTML Now let's tie it all together: Start with server-rendered HTML Bootstrap the SPA off that Client-side render from there...
  • 37. APP HTML TEMPLATE <body> <div class="js-content"> {{{content}}} </div> <script class="js-initial-data" type="application/json"> {{{initialData}}} </script> <script src="/app/js-dist/bundle.js"></script> </body>
  • 38. CONCLUSION  Render and let React handle DOM diffing  Server-side rendering is easy  Leave jQuery behind
  • 39. PARTING THOUGHTS Dataflow is... different Dive in more to the ecosystem: , Flux React router, etc.
  • 40. RESOURCES todomvc.com/examples/react-backbone github.com/jhudson8/backbone-reaction github.com/clayallsopp/react.backbone github.com/magalhas/backbone-react-component
  • 41. THANKS! slides.formidablelabs.com /201411-react-backbone.html  |  @ryan_roemer formidablelabs.com