Summer Sale! All accounts are 50% off this week.

parthp1808's avatar

Single Vue Instance vs Multiple instances per page for Laravel

Hey, I am building a multi-page laravel application and want to start using vuejs for some tweaks and enhancements. I am confused whether to start with multiple instance or single instance at root. If I use single instance , then will it work on multiple pages ?

0 likes
5 replies
robrogers3's avatar
Level 37

You should check out the laracasts series 'Let's Build A Forum with Laravel and TDD'

It was after watching this that I learned why using multiple vue instances is a MISTAKE. And now I'm stuck with it.

If you have a single app instance, and you register all your components then you never have to worry about whether certain vue instances should be available on which pages. Which is now my headache.

In short: 1 vue instance. 2 lots of components.

just look at how the default laravel ships with it's components. and an empty vue instance.

4 likes
parthp1808's avatar

Thanks @robrogers3 Makes sense. Laravel by default comes with one single root vue instance. Thanks for the clarification

robrogers3's avatar

yeah, don't make the mistake I did!! I'm paying for it.

remember, if you can't do component templates for everything there is always the inline template option!!

1 like
Robstar's avatar

The only issue I see with this is with heavy components. I'm aware you import components on demand. Some larger components (for example, an order screen I'm working on) require Vuex and multiple stores. I wouldn't want to load stuff like this on every request.

debuGhy's avatar

I know I am replying late on this but I am kind of stuck. Actually I am using laravel and vuejs in a project. I am using vue components within laravel but I have a problem. I want to separate html for admin routes and user routes. Admin will have it own login,dashboard page & the user will have its own profile with different layout. How can I achieve it?

Please or to participate in this conversation.