You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: en/README.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,7 @@ If you're using webpack, you can easily add prerendering with the [prerender-spa
41
41
42
42
## About This Guide
43
43
44
-
This guide is focused on server-rendered Single-Page Applications using Node.js as the server. Mixing Vue SSR with other backend setups is a topic of its own and is not covered in this guide.
44
+
This guide is focused on server-rendered Single-Page Applications using Node.js as the server. Mixing Vue SSR with other backend setups is a topic of its own and briefly discussed in a [dedicated section](./non-node.md).
45
45
46
46
This guide will be very in-depth and assumes you are already familiar with Vue.js itself, and have decent working knowledge of Node.js and webpack. If you prefer a higher-level solution that provides a smooth out-of-the-box experience, you should probably give [Nuxt.js](https://nuxtjs.org/) a try. It's built upon the same Vue stack but abstracts away a lot of the boilerplate, and provides some extra features such as static site generation. However, it may not suit your use case if you need more direct control of your app's structure. Regardless, it would still be beneficial to read through this guide to better understand how things work together.
Render a Vue instance to string. The context object is optional. The callback is a typical Node.js style callback where the first argument is the error and the second argument is the rendered string.
36
36
37
-
-#### `renderer.renderToStream(vm[, context])`
37
+
In 2.5.0+, the callback is also optional. When no callback is passed, the method returns a Promise which resolves to the rendered HTML.
38
38
39
-
Render a Vue instance to a Node.js stream. The context object is optional. See [Streaming](./streaming.md) for more details.
Render a Vue instance to a [Node.js readble stream](https://nodejs.org/dist/latest-v8.x/docs/api/stream.html#stream_readable_streams). The context object is optional. See [Streaming](./streaming.md) for more details.
Render the bundle to a string. The context object is optional. The callback is a typical Node.js style callback where the first argument is the error and the second argument is the rendered string.
46
48
47
-
-#### `bundleRenderer.renderToStream([context])`
49
+
In 2.5.0+, the callback is also optional. When no callback is passed, the method returns a Promise which resolves to the rendered HTML.
Render the bundle to a Node.js stream. The context object is optional. See [Streaming](./streaming.md) for more details.
53
+
Render the bundle to a [Node.js readble stream](https://nodejs.org/dist/latest-v8.x/docs/api/stream.html#stream_readable_streams). The context object is optional. See [Streaming](./streaming.md) for more details.
50
54
51
55
## Renderer Options
52
56
@@ -67,6 +71,8 @@ See [Introducing the Server Bundle](./bundle-renderer.md) and [Build Configurati
67
71
68
72
-`context.state`: (Object) initial Vuex store state that should be inlined in the page as `window.__INITIAL_STATE__`. The inlined JSON is automatically sanitized with [serialize-javascript](https://github.com/yahoo/serialize-javascript) to prevent XSS.
69
73
74
+
In 2.5.0+, the embed script also self-removes in production mode.
75
+
70
76
In addition, when `clientManifest` is also provided, the template automatically injects the following:
71
77
72
78
- Client-side JavaScript and CSS assets needed by the render (with async chunks automatically inferred);
@@ -125,6 +131,14 @@ See [Introducing the Server Bundle](./bundle-renderer.md) and [Build Configurati
125
131
})
126
132
```
127
133
134
+
-#### `shouldPrefetch`
135
+
136
+
- 2.5.0+
137
+
138
+
A function to control what files should have `<link rel="prefetch">` resource hints generated.
139
+
140
+
By default, all assets in async chunks will be prefetched since this is a low-priority directive; however you can customize what to prefetch in order to better control bandwidth usage. This option expects the same function signature as `shouldPreload`.
The default build of `vue-server-renderer` assumes a Node.js environment, which makes it unusable in alternative JavaScript environments such as [php-v8js](https://github.com/phpv8/v8js) or [Nashorn](https://docs.oracle.com/javase/8/docs/technotes/guides/scripting/nashorn/). In 2.5 we have shipped a build in `vue-server-renderer/basic.js` that is largely environment-agnostic, which makes it usable in the environments mentioned above.
4
+
5
+
For both environments, it is necessary to first prepare the environment by mocking the `global` and `process` objects, with `process.env.VUE_ENV` set to `"server"`, and `process.env.NODE_ENV` set to `"development"` or `"production"`.
6
+
7
+
In Nashorn, it may also be necessary to provide a polyfill for `Promise` or `setTimeout` using Java's native timers.
0 commit comments