Skip to content

Commit 7363a44

Browse files
committed
add start to ssr doc
1 parent 56ce799 commit 7363a44

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/guide/ssr.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,30 @@ type: guide
44
order: 25
55
---
66

7-
## Introduction
7+
## Hello World
88

9+
Server-side rendering (i.e. SSR) sounds complex, but a simple node script demoing the feature requires only 3 steps:
10+
11+
``` js
12+
// Step 1: Create a Vue instance
13+
var Vue = require('vue')
14+
var vm = new Vue({
15+
render: function(h) {
16+
return h('p', 'hello world')
17+
}
18+
})
19+
20+
// Step 2: Create a renderer
21+
var renderer = require('vue-server-renderer').createRenderer()
22+
23+
// Step 3: Render the Vue instance to HTML
24+
renderer.renderToString(vm, function (error, html) {
25+
if (error) throw error
26+
console.log(html)
27+
// => <p server-rendered="true">hello world</p>
28+
})
29+
```
30+
31+
Not so scary, right? In the rest of this guide, we'll give you a broad overview of how SSR works with the most common use cases. Once you understand the basics, we'll share some more detailed documentation and advanced examples to help you handle any edge cases.
32+
33+
## !!TODO: Finish this guide

0 commit comments

Comments
 (0)