0

I'm trying to find a simple server-side rendering solution for Vue.js, but every example or tutorial I've found has dependencies I don't want to include that overcomplicate things: usually webpack, Vue Router, and Vuex.

I'm looking for a solution that runs in Node.js and can render a .vue file to a string, including any other .vue files it may reference.

const sfcContent = fs.readFileSync("./app.vue", "utf-8");
const props = {
  foo: "bar",
};
const htmlString = await render(sfcContent, props);

console.log(htmlString);

async function render(sfcContent, props) {
  // this is the function I'm looking for
}

http-vue-loader looks promising, as it does roughly what I'm looking for except in the browser instead of Node.js.

Any ideas what I should try?

1 Answer 1

1

You could look into the compiler-utils package https://github.com/vuejs/component-compiler-utils

Although, this will still require some tinkering on your end so I'm not sure if it'll be the way to go if you don't want to overcomplicate things.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.