Server
App
Render
<div> Hello world! </div>
Server
App
Render
<html>
<ul>
<li>James Holden</li>
<li>Naomi Nagata</li>
</ul>
</html>
Database
Read
Browser
Request page
Send HTML
<html>
<a>Roccinante crew</a>
</html>
<html>
<ul>
<li>James Holden</li>
<li>Naomi Nagata</li>
</ul>
</html>
Replace the whole page
Request page
Receiving page
Received page
Click button
Request page
Database Read
Receiving page
Received page
Server
API
Database
Read
Browser
Request page
Send JSON
<html>
<div id="app">
<a>Roccinante crew</a>
</div>
</html>
<html>
<div id="app">
<ul>
<li>James Holden</li>
<li>Naomi Nagata</li>
</ul>
</div>
</html>
CDN
HTML
JS
Request API
Request script
<html>
<div id="app"></div>
</html>
<html>
<div id="app">
<div class="loading"/>
</div>
</html>
App
Request page
Received JS
Click button
Change route
Request API
Database Read
Received JSON
Received page
Request JS
Server
API
Database
Read
Browser
Request page
Send JSON
<html>
<div id="app">
<a>Roccinante crew</a>
</div>
</html>
<html>
<div id="app">
<ul>
<li>James Holden</li>
<li>Naomi Nagata</li>
</ul>
</div>
</html>
CDN
JS
Request API
Request script
<html>
<div id="app">
<div class="loading"/>
</div>
</html>
Hydration
Server
App
JS
App
Request page
Received JS
Click button
Change route
Request API
Database Read
Received JSON
Receiving page
Received page
Request JS
Server
API
Database
Read
Browser
Request page
Send JSON
<html>
<div id="app">
<ul>
<li>James Holden</li>
<li>Naomi Nagata</li>
</ul>
</div>
</html>
CDN
JS
Request API
Request script
Server
App
Hydration
JS
App
Request page
Received page
Request JS
Received JS
Database Read
Receiving page
API
App
Browser
CrewList.vue
router
state
renderer
CrewList.vue instance
<html>
<div id="app">
<ul>
<li>James Holden</li>
<li>Naomi Nagata</li>
</ul>
</div>
</html>
{
crew: [
{
firstname: 'James',
lastname: 'Holden'
},
{
firstname: 'Naomi',
lastname: 'Nagata'
}
]
}
Request page
Push route
Match component
definition
Call
Receive data
Save data
Inject state
to context
Passed to
Create
Use
Data Prefetching
App
state
$mount('#app')
Restore state
Mount to the DOM
API
App
Browser
CrewList.vue
router
state
renderer
CrewList.vue instance
<html>
<div id="app">
<ul>
<li>James Holden</li>
<li>Naomi Nagata</li>
</ul>
</div>
</html>
{
crew: [
{
firstname: 'James',
lastname: 'Holden'
},
{
firstname: 'Naomi',
lastname: 'Nagata'
}
]
}
Request page
Push route
Match component
definition
Call
Receive data
Save data
Inject state
to context
Passed to
Create
Use
Data Prefetching
Only route components
No access to `this` (no instance)
API
App
Browser
router
state
renderer
CrewList.vue instance
<html>
<div id="app">
<ul>
<li>James Holden</li>
<li>Naomi Nagata</li>
</ul>
</div>
</html>
{
crew: [
{
firstname: 'James',
lastname: 'Holden'
},
{
firstname: 'Naomi',
lastname: 'Nagata'
}
]
}
Request page
Push route
Call
Receive data
Inject state to context
Passed to
Create
Save data
Data
Prefetching
+ Rendering
Combined
context.rendered hook
create component instance
prefetch data
render component
continue with children
App
state
$mount('#app')
Restore state
Mount to the DOM
Silver sponsor
Bronze sponsor
Guillaume Chau
@Akryum
github.com/Akryum