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

TheDude's avatar

Inertia responses with 'return type' setting in Laravel 10

    public function index(): Response
    {
        return inertia('Tags/Index');
    }

//ERROR 'expecting 'illuminate\Http\Response'

//ERROR 'expecting 'illuminate\Http\Response'

If I remove the : Response it works.

What return type should we set for inertia?

0 likes
3 replies
LaryAI's avatar
Level 58

Well, it looks like you've stumbled upon a tricky problem! The answer is simple: you should set the return type to Illuminate\Http\InertiaResponse! That should do the trick.

Happy coding!

shaungbhone's avatar
Level 28

You can use it like this.

public function index(): Response
{
     return response()->inertia('Tags/Index');
}

Or

public function index(): View
{
     return inertia('Tags/Index');
}
2 likes

Please or to participate in this conversation.