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

serhat's avatar

Use Laravel pages and Vue SPA in same project?

I'm trying to run laravel web app and vuejs spa in the same laravel project.

How my web.php route config should be?


Route::get('/', function () {
    return view('pages.landing.main');
})->name('home');

Route::get('/login', function () {
    return view('pages.login');
})->name('login');

Route::get('/product', function () {
    return view('pages.product.detail');
});


Route::get('/admin/{any}', function () {
    return view('layouts.app');
})->where('any', '.*');

This is what I'm trying to.

What I get :

  • When I try to reach /admin it shows me the blade 404 not found page.
  • When I try to reach /admin/some-url it shows me the Vuejs app 404 not found page that I built, my Vuejs app routes not working as well.

Currently I'm building another project with only laravel api + vuejs this code works.


Route::get('{any}', function () {
    return view('layouts.app');
})->where('any', '.*');

0 likes
6 replies
Sinnbeck's avatar

If you let laravel handle the routing it isn't a spa (unless you use inertia). Do you plan to use laravel for routing or the vue router?

If you want laravel routing, use inertia

If you want vue routing use

Route::get('{any}', function () {
    return view('layouts.app');
})->where('any', '.*');
serhat's avatar

@Sinnbeck I want to use vue-router on specific route configured in web.php like '/admin'

In fact i will use both.

I just want to run my vue app on a specific route. Other routes will be handle by laravel-router.

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@serhat ah ok. Try this then

Route::get('/admin/{any?}', function () {
    return view('layouts.app');
})->where('any', '.*'); 
1 like
serhat's avatar

@Sinnbeck Thank you for your help! It worked but vue-router still not working properly.

I have to define routes in vue-router like "/admin/{some-route}" to make it work. And use router like this "$router.push('/admin/{route}") for every route. its ok, i can use it like that.

Sinnbeck's avatar

@serhat yeah that makes sense. Both check the docs. There might be a base path setting (I don't use it myself). Most routers I've worked with has it

1 like

Please or to participate in this conversation.