0

I started a project few months ago with Laravel and for a specific feature: jQuery (with over 6-7k lines) that I dropped because I was not satisfied at all with maintenability of jQuery.

There will be some features like members account, news and this application. I switched to React to build this application from scratch but I want the other features of the website managed by Laravel (I won't need any JavaScript).

My question is : is it fine to build some blade views (home, account) and one view for this application (application.blade.php) with only some id to manage my React components?

<div class="container">
    <div id="myc1"></div>
    <div id="myc2"></div>
     ....
</div>

Or is it a very bad practice/idea?

3
  • 2
    React is typically used to create an SPA, in that case the communication with the server happens via AJAX and JSON usually. You could use views and serve multiple React apps, but whether that's a sensible thing to do is just people's opinion and thus it's OT for this website. Commented Jan 9, 2019 at 0:43
  • 1
    yes it's fine. React is just another javascript lib, use as much or as little as you want Commented Jan 9, 2019 at 0:44
  • 1
    It's not a bad practice. There are many MPA apps out there that utilize Vue, React, and Angular to handle specific components of their site. You don't have to build an SPA. Commented Jan 9, 2019 at 0:45

1 Answer 1

1

yes it's a fine way but I advise you to use vue.js* with Laravel not jquery *[Vue.js is an open-source JavaScript framework for building user interfaces and single-page applications.] Why should you use Vue.js when using Laravel? If you have used a recent Laravel version, you would notice it usually comes with Vue bundled in with other tools like Bootstrap and jQuery. You would also notice in Laravel documentation that they gave a small introduction to using Vue components Vue integrates nicely with Laravel. You can create Vue components and use them like you would use regular HTML tags inside your blade file. You can pass props to the component from the output generated when your blade file renders.

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

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.