How to use Laravel Nova without AuthenticationRoutes

It’s really simple to use your own login and logout routes and skipping the authentication routes of Nova entirely.

Start by remove or commenting the withAuthenticationRoutes and withPasswordResetRoutes lines in NovaServiceProvider.php:

protected function routes()
    {
        Nova::routes()
//            ->withAuthenticationRoutes()
//            ->withPasswordResetRoutes()
            ->register();
    }

With these routes removed, you will encounter the following error when loading a Laravel Nova view:

Route [nova.logout] not defined. (View: .../resources/views/vendor/nova/partials/user.blade.php)

The error is thrown because Nova is not registering the nova.logout route anymore, but is still referencing it in the dropdown menu.

If the user.blade.php file is located in /vendor/laravel/nova/resources/views/partials/user.blade.php, you should publish the Nova views first. To do this, run php artisan nova:publish.

With the user.blade.php located in /resources/views/vendor/nova/partials, open the file, and remove the following lines:

<li>
    <a href="{{ route('nova.logout') }}" class="block no-underline text-90 hover:bg-30 p-3">
        {{ __('Logout') }}
    </a>
</li>

And replace it with:

<li>
    <form id="logout-form" action="{{ route('logout') }}" method="POST">
        @csrf
        <button type="submit" class="block no-underline text-90 hover:bg-30 p-3 w-full text-left">Logout</button>
    </form>
</li>

Instead of getting redirected to Nova’s logout route, clicking the button submits a POST request to the default logout route (which only accepts POST request).

This is it. When trying to access Nova while logged out, you are redirected to the login route which sends you back to the url you tried to access after a successful login. And when you are logged in, you can still logout using the button in the dropdown menu. You have successfully removed Nova’s authentication routes!