Home » vue » Vue.js SSR – how to require vue-server-renderer with import instead?

Vue.js SSR – how to require vue-server-renderer with import instead?

Posted by: admin November 26, 2021 Leave a comment

Questions:

How can I require vue-server-renderer with import instead?

const renderer = require('vue-server-renderer').createRenderer()

I tried:

import renderer from 'vue-server-renderer'
const vueRenderer = renderer.createRenderer()

Error:

var vueRenderer = _vueServerRenderer2.default.createRenderer();
                                             ^
TypeError: Cannot read property 'createRenderer' of undefined

Any ideas?

Answers:

createRenderer – export function in package vue-server-renderer

import {createRenderer} from 'vue-server-renderer'

const renderer = createRenderer()