spoonego's avatar

Analysis paralysis: Help choosing the right tools.

Hi everyone , I hit a crossroads choosing what packages use with laravel for our company's app full rewrite.

For context the app is a tourist guide so we have hotels, restaurants, attractions and events, the restaurants, attractions and events are managed by us, the hotels also but we also have a booking engine that hotels can use, so the app is something like this : example.com/ (regular site), example.com/admin (our admin panel), example.com/hotel-manager (the hotel's saas ) .

My crossroad is what tech would be better, I was thinking going the traditional route, with just blade, an api, and react but learning about inertiajs and live wire, my second aproach could be livewire for the site because SEO, inertiajs for the admin and hotel saas, the problem with this approach is that I haven't seen any guide in how to have 2 inertiajs projects in one laravel setup (maybe this is just one injertiajs project and i'll have to choose one layout over the other depending the user type?) other thing to consider is that the site has a couple of heavy js widgets that in the case of livewire we will have to write with alpine js so I will have the same problem I have today having to maintain 2 separate javascript codebases (as of today we maintain a jquery and vuejs codebases) with no relation between them. The third option would be to go all in on inertiajs with ssr on the site but now I don't know if its posible to have 3 separate inertiajs projects in one laravel setup and adding the fact that I would have to use 3rd party libraries to get SEO back, but this approach lets me have one js code base and reuse functions between the 3 parts of the site and the js widgets that we have would be a walk in the part to rewrite in reactjs.

What do you think would be the best approach , just r*w dog blade, reactjs and an API ; livewire and inertia and wrestle a little with the routes, or inertiajs all the way but now adding nodejs to render the main site and wrestle with the +3 routes (admin, hotel saas and the site routes) ?

0 likes
3 replies
RemiM's avatar

All options are viable, but following the KISS principle is generally the best approach. However, the decision depends on several factors, such as:

  • The team size and their personal expertise
  • Deployment constraints and budget considerations
  • Whether you prioritize flexibility over simplicity

In your case, I would likely opt for a full Inertia setup with SSR capabilities, structured as follows:

  • Public-facing site with SSR enabled
  • Admin panel as a standard SPA
  • Hotel manager dashboard as a standard SPA

You don’t need separate Inertia instances, just different layouts based on the route prefix:

<?php

// Public routes with SSR
Route::middleware(['inertia.ssr'])->group(function () {
    Route::get('/', [HomeController::class, 'index'])->name('home');
    ...
});

// Admin routes
Route::prefix('admin')
    ->name('admin.')
    ->middleware(['auth:admin'])
    ->group(function () {
        Route::get('/', [AdminDashboardController::class, 'index'])->name('dashboard');
        // Admin resources
    });

// Hotel manager routes
Route::prefix('hotel-manager')
    ->name('hotel.')
    ->middleware(['auth:hotel'])
    ->group(function () {
        Route::get('/', [HotelDashboardController::class, 'index'])->name('dashboard');
		// Hotel resources
    });

Using this approach would give you:

  • SEO for the public site (via SSR)
  • Unified JS approach (Inertia throughout)
  • Clear separation between the three "sections"
  • Easy way to add functionality to each section
1 like
spoonego's avatar

@RemiM Thanks, I talked with my team (just me and other guy lol) and we are going all the way with inertia and ssr.

Just a quick question where I can find the full code example of the snippet you posted. I got an error saying that 'inertia.ssr' does not exists. Also we are using laravel 12, was that example from an older version of laravel?

Thanks for your help.

RemiM's avatar

@spoonego This is a basic example, to give you the general idea on how you could approach the issue you are facing. As for the error, it's normal: you will have to implement the custom middleware to make it work.

Here is a working example, I just changed the name of the middleware for better readability, and tackle the problem the other way around. Now the middleware is applied to groups that don't need SSR, since SSR is enabled by default:

  1. You would have a middleware named DisableSSR.php:
<?php
namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Config;
use Symfony\Component\HttpFoundation\Response;

class DisableSSR
{
    public function handle(Closure $next): Response
    {
        Config::set('inertia.ssr.enabled', false);

        return $next($request);
    }
}
  1. You would update your bootstrap/app.php to include the middleware:
->withMiddleware(function (Middleware $middleware) {
        $middleware->encryptCookies(except: ['appearance']);

		// Here is the custom middleware with an alias
        $middleware->alias([
            'disableSSR' => DisableSSR::class,
        ]);

        $middleware->web(append: [
            HandleAppearance::class,
            HandleInertiaRequests::class,
            AddLinkHeadersForPreloadedAssets::class,
        ]);
    })
  1. You add the middleware to the group where you don't want SSR in your routes file/files:
<?php

// Public routes with SSR
Route->group(function () {
    Route::get('/', [HomeController::class, 'index'])->name('home');
    ...
});

// Admin routes
Route::prefix('admin')
    ->name('admin.')
    ->middleware(['auth:admin', 'disableSSR'])
    ->group(function () {
        Route::get('/', [AdminDashboardController::class, 'index'])->name('dashboard');
        // Admin resources
    });

// Hotel manager routes
Route::prefix('hotel-manager')
    ->name('hotel.')
    ->middleware(['auth:hotel',  'disableSSR'])
    ->group(function () {
        Route::get('/', [HotelDashboardController::class, 'index'])->name('dashboard');
		// Hotel resources
    });
  1. After creating or updating middleware, don't forget to clean your config, and eventually your routes:
php artisan config:clear
php artisan route:clear
composer dump-autoload

Now, there a many ways to make it work, middleware is one of them, you could also go by adding conditional logic in your blade file, or creating a new HTTP Gateway.

See here for some details: https://github.com/inertiajs/inertia/discussions/1429

Please or to participate in this conversation.