vue3-bundle-renderer
v1.0.5
Published
## Quick Start
Downloads
13
Readme
vue3-bundle-renderer
Quick Start
npm install vue3-bundle-renderer
import { createBundleRenderer } from 'vue3-bundle-renderer';
// ssr server 端的资源
const serverBundle = {};
// ssr client 端的资源
const clientManifest = {};
// ssr context
const ssrContext = {};
const bundleRenderer = createBundleRenderer({
serverBundle,
clientManifest,
runInNewContext: false,
});
async function render(req, res) {
// ssr context
const ssrContext = {
url: req.url,
hostname: req.hostname,
};
bundleRenderer
.renderToString(ssrContext)
.then((html) => {
res.send(html);
})
.catch((err) => {
res.send(err.message);
});
}