Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement SSR for single vue component inside of laravel application?

I'm working on an laravel project. There're a lot of vue components and I need to make SSR due to SEO. I can't use nuxt.js or something like it because of my app is not SPA. I have default mix settings:

const mix = require('laravel-mix');
mix.js('resources/js/app.js', 'public/js')
   .sass('resources/sass/app.sass', 'public/css');
mix.disableSuccessNotifications();

I put the vue components to laravel views (blade templates) like <example-component></example-component>. How may I implement SSR for there components only in this case?

I need to add this components as rendered html to the response, not as <example-component></example-component> due to SEO.

like image 392
Alexxosipov Avatar asked Mar 11 '19 11:03

Alexxosipov


1 Answers

Server side rendering is not a one liner, but there are a package for laravel to do it, please check it out:

https://github.com/spatie/laravel-server-side-rendering

like image 158
Apród Illés Avatar answered Oct 06 '22 22:10

Apród Illés