Skip to content

Instantly share code, notes, and snippets.

@Maxim-Kolmogorov
Last active November 20, 2022 17:45
Show Gist options
  • Select an option

  • Save Maxim-Kolmogorov/a3bd43eba5bb71c51c269dd99e1b516d to your computer and use it in GitHub Desktop.

Select an option

Save Maxim-Kolmogorov/a3bd43eba5bb71c51c269dd99e1b516d to your computer and use it in GitHub Desktop.
Laravel 9 + Vite + Vue.js + SSR = example, part 7
/* global var process from node */
import { createSSRApp } from 'vue'
import { renderToString } from 'vue/server-renderer'
import router from './router.js';
import App from './App.vue';
(async function main() {
const requestUrl = process.argv[2] || '/';
const app = createSSRApp(App);
app.use(router);
// Пушим путь в router, если перешли на компонент напрямую
await router.push(requestUrl);
await router.isReady();
const html = await renderToString(app);
process.stdout.write(html);
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment