11

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.

7
  • what is mean by SSR? Commented Mar 11, 2019 at 11:20
  • @arun server-side rendering Commented Mar 11, 2019 at 11:21
  • You may not need to do SSR for SEO. It could be enough to only render the necessary information for SEO. Google does not consider this as cloaking. Commented Mar 11, 2019 at 11:28
  • 1
    @RaduDiță before asking a question here, I asked about it on webmasters.stackoverflow: webmasters.stackexchange.com/questions/121490 check it out, I guess I need to do SSR here Commented Mar 11, 2019 at 11:41
  • 1
    This is a great resource sebastiandedeyne.com/server-side-rendering-javascript-from-php Commented Mar 13, 2019 at 22:16

3 Answers 3

3
+25

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

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

Comments

0

The current solutions require the use of Node, or in extreme cases PHP in combination with V8Js engine.

See https://ssr.vuejs.org/guide/#integrating-with-a-server to get you started. vue-server-renderer is based on a Node/express.js implementation that renders your HTML beforehand.

I have not yet tried any solution that is PHP based and unfortunately this is the best answer I can give to you at the moment.

1 Comment

I wouldn't consider a PHP renderer an "extreme case" - you gain the familiarity and separation of having SSR done with something you're comfortable with. That's why there are packages from RoR and Laravel that are so popular
-3

Use only blade. Don't use components of Vue. You can use them for unecessary things of Clawer, Search Engine like Forms, Payment, Bookings, Carts, Check Out,

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.