Skip to content

Commit 4b288b9

Browse files
committed
SSR docs
1 parent df4a696 commit 4b288b9

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

docs/.vuepress/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ module.exports = {
4242
title: 'Advanced Topics',
4343
collapsable: false,
4444
children: [
45+
'/guide/nuxt',
4546
'/guide/adapters',
4647
'/guide/connection-mode',
4748
'/guide/custom-queries',

docs/guide/nuxt.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Nuxt.js / SSR Integration
2+
3+
[[toc]]
4+
5+
Since Version 1.0.0.RC.21 there is support for SSR. You will need
6+
[node-fetch](https://www.npmjs.com/package/node-fetch) in order to make it work and you have to
7+
construct your own HttpLink instance.
8+
9+
Example store setup for nuxt.js:
10+
11+
```javascript{13,14,15}
12+
import Vuex from 'vuex';
13+
import VuexORM from '@vuex-orm/core';
14+
import VuexORMGraphQL from '@vuex-orm/plugin-graphql';
15+
import { HttpLink } from 'apollo-link-http';
16+
import database from './database';
17+
import fetch from 'node-fetch';
18+
19+
const options = {
20+
database,
21+
url: process.env.BACKEND_URL + '/api/v2',
22+
};
23+
24+
if (process.server) {
25+
options.link = new HttpLink({ uri: options.url, fetch });
26+
}
27+
28+
VuexORM.use(VuexORMGraphQL, options);
29+
30+
31+
export default function createStore () {
32+
const plugins = [VuexORM.install(database)];
33+
return new Vuex.Store({ plugins });
34+
}
35+
```

0 commit comments

Comments
 (0)