Posts Learn Components Snippets Categories Tags Tools About
/

Laravel Blade @auth Example

Learn how to check for authenticated user in Laravel using @auth directive

Created on Aug 06, 2021

1092 views

It's very common to check whether a user is authenticated in Laravel by using the "@if" blade directive. But instead of writing the logic which is quite long, you can easily make use of the "@auth" to replace it.

The common way using "@if" blade directive.
@if (auth()->user())
    // the user is authenticated
@endif

When using "@auth" blade directive.
@auth
    // the user is authenticated
@endauth

If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️

Load comments for Laravel Blade @auth Example

new

PostSrc Code Components

Collection of Tailwind CSS components for everyone to use. Browse all of the components that are right for your project.

View Components

Sponsors 👑

+ Add Yours
)