Posts Learn Components Snippets Categories Tags About

Laravel Blade @auth Example

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

Created on Aug 06, 2021


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

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

Snippets by

PostSrc poster


Full stack developer mainly focusing on the front end side of the web. The main author of PostSrc and loves writing tutorial and guides online.

Load comments for Laravel Blade @auth Example


PostSrc Code Components

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

View Components

Other Code Snippets