
Vue rendering engine for Express.js
A Simple way of using Server Side rendered Vue.js 2.0+ natively in Express using streams
Installation
npm install --save express-vue
ES Modules
If using ES module statments like
export default {}
//or
import foo from "foo";
Or any other ES features you will need to also install babel-core and babel-preset-env.
npm i -D babel-core babel-preset-env
Then place a .babelrc file in your root. here's an example targeting last two versions
{
"presets": [
["env", {
"targets": {
"browsers": ["last 2 versions"]
}
}]
]
}
Usage
var expressVue = require("express-vue");
var app = express();
const expressVueMiddleware = expressVue.init();
app.use(expressVueMiddleware);
In your route, assuming you have a main.vue
router.get('/', (req, res, next) => {
const data: {
otherData: 'Something Else'
};
req.vueOptions: {
head: {
title: 'Page Title',
metas: [
{ property:'og:title', content: 'Page Title'},
{ name:'twitter:title', content: 'Page Title'},
]
}
}
res.renderVue('main.vue', data, req.vueOptions);
})




