Skip to content
Discussion options

You must be logged in to vote

Hey @Aniket-IN
you can check for Inertia's Header - it will only be there on an Inertia vist. Initial visits do not contain the header. This way you can achieve the desired "load once" behaviour, e.g.

use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;

class ExampleController
{
    public function __invoke(Request $request): Response
    {
        return Inertia::render('Example', [
            'onlyOnInitialVisit' => !$request->inertia() ? 'Hello World' : null,
        ]);
    }
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Aniket-IN
Comment options

Answer selected by Aniket-IN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants