In Vue, all your code is encapsulated in a Vue instance
. Components are just a special type of Vue instance. And Vue instances have a very special property: you can instantiate them in Node.js
Other frontend frameworks struggle with server-side rendering
because your code is inherently tied to the DOM. For example, with React, you don’t get a standalone object that represents your app. You instead use the react-dom package
to bootstrap your app, using completely different code than you would if you were bootstrapping your app to the DOM.
With Vue, server-side is less of a hacky afterthought and more of a first-class citizen. The design decision to have an object encapsulating your entire app has several neat consequences. Here’s 3: