TomMcEvoy
2 weeks ago
302
7
Laravel

Laravel 8, Jetsteam, Inertia change login view

Posted 2 weeks ago by TomMcEvoy

The Laravel Jetstream documentation says for simplicity the scaffolding for login etc are written as blade and do not use a Javascript framework. Under the old Laravel/Ui package, it was possible to change the default login view through the showLoginForm() method in the controller.

How can I change the default login view using Jetstream/Fortify? For example I want to render the login page using Inertia rather than blade.

I know there is a Fortify::loginView() method which can be added to the boot method in the FortifyServiceProvider. But this won't work with the Inertia::render method. For example:

Fortify::loginView(function () {
   return Inertia::render('Auth/Login');
});

This throws an error message:

Argument 1 passed to Symfony\Component\HttpFoundation\Response::setContent() must be of the type string or null, object given

I'm probably missing something simple, but the documentation is so sparse at the moment, I'm stuck.

Please sign in or create an account to participate in this conversation.