Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kevbrn's avatar
Level 14

Conditional vue component in blade

What would be the "right" way to accomplish the following.

render a vuejs component in blade depending on the url?

@if(some url string)
    <component-one></component-one>
@elseif(some other url string)
    <component-two></component-two>

....

or with vue-router maybe? or vue dynamic components?

Just looking for the more correct way to go about this.

Thanks, Kevin

0 likes
2 replies
Drfraker's avatar

If you are loading it based on the route anyway, why not add a new route and show an entirely different *.blade.php view for each route?

kevbrn's avatar
Level 14

@Drfraker thanks, that's pretty much how I have it set up at the moment but seeing as an individual component can (and in the case of my app) make up 100% of the rendered content why keep making blade files? Thinking it would be similar to an SPA maybe?

Please or to participate in this conversation.