New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

ronasit/laravel-clerk

Package provides auth guard to auth user via the Clerk
21,382 10

Larablocks Analysis

ronasit/laravel-clerk works with Laravel 11, 12 and 13 (latest release 1.2, Sep 22, 2026).

Recommendation checks

Solid choice

Solid choice: maintained and up to date, meets 2 of 4 checks; below the bar for Recommended on use.

  • Works with Laravel 13, the current version
  • Released in the last 12 months (Sep 22, 2026)
  • 1,807 downloads a month (needs 10,000)
  • 10 GitHub stars (needs 100)

State

Actively maintained
  • Last stable release: Sep 22, 2026.
  • 3 releases in the last 12 months.
  • First released: Nov 4, 2024.
  • Monthly downloads: 1,807.
  • 4 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Nov 30, 2026.

Install
composer require ronasit/laravel-clerk
Latest Version:1.2
PHP:^8.3
Laravel:11 · 12 · 13
License:MIT
Last Updated:Oct 23, 2026
Links: GitHub  ·  Packagist
Maintainer: eleonov

Coverage Status

Laravel Clerk Guard

Introduction

This package offers an authentication guard to seamlessly integrate Clerk authentication into your Laravel project.

Installation

  1. Use Composer to install the package:
composer require ronasit/laravel-clerk
  1. Run package's install command
php artisan laravel-clerk:install
  1. Populate the necessary configuration options in config/clerk.php.

Configuration

Set the following environment variables to configure the package:

  • CLERK_ALLOWED_ISSUER — the expected iss claim value of incoming JWT tokens.
  • CLERK_ALLOWED_ORIGINS — comma-separated list of allowed azp claim values.
  • CLERK_SECRET_KEY — your Clerk API secret key, used to verify the token signature.
  • CLERK_SIGNER_KEY — base64-encoded PEM content of the public JWT key. Takes priority over CLERK_SIGNER_KEY_PATH when set.
  • CLERK_SIGNER_KEY_PATH — path to the public JWT key file, relative to base_path(). Defaults to clerk.pem. Used as a fallback when CLERK_SIGNER_KEY is not set.

You can find the public JWT key in your Clerk dashboard under "Configure" → "API keys" → "JWKS Public Key".

Since a PEM block is multi-line, encode it with base64 before placing it into CLERK_SIGNER_KEY:

base64 < clerk.pem | tr -d '\n'

Usage

By default, your app returns the User class with just the external_id property, which holds the user's ID in Clerk.

To customize this behavior, you'll need to create your own UserRepository that implements the UserRepositoryContract. Then, rebind it in one of the service providers:

use RonasIT\Clerk\Contracts\UserRepositoryContract;
use App\Support\Clerk\MyAwesomeUserRepository;

class AppServiceProvider extends ServiceProvider
{
    public function boot(): void
    {
        $this->app->bind(UserRepositoryContract::class, MyAwesomeUserRepository::class);
    }
}

Testing

To test authenticated user requests guarded by ClerkGuard, use the TokenMockTrait:

  1. Ensure clerk config is filled using .env.testing file or dynamically. The signer key is set automatically:
Config::set('clerk', [
    'allowed_issuer' => 'issuer',
    'secret_key' => 'my_secret_key',
]);
  1. Generate a JWT token and pass it to the Authorization header:
use RonasIT\Clerk\Traits\TokenMockTrait;

class UserRepositoryTest extends TestCase
{
    use TokenMockTrait;
    
    public function test()
    {
        $clerkToken = $this
            ->createJWTToken(
                relatedTo: 'user_id',
                issuer: 'issuer',
            )
            ->toString();
            
        $this->withHeader('Authorization', "Bearer {$clerkToken}");     
    }
}
  1. You may also pass custom claims to the token using claims parameter:
    $clerkToken = $this
        ->createJWTToken(
            relatedTo: 'user_id',
            issuer: 'issuer',
            claims: [
                'email' => 'user@mail.com',
                'phone' => '+1234567789',
            ],
        )->toString();

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

670,032,257 9,703
laravel/framework

The Laravel Framework.

640,572,096 35,338
laravel/tinker

Powerful REPL for the Laravel framework.

546,909,908 7,440
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

465,816,364 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

438,010,529 4,660

Version History

Version Released PHP Laravel License
1.2 ^8.3 >=11 MIT
1.1.2 ^8.3 >=11 MIT
1.1.1 ^8.3 >=11.34 MIT
1.1 ^8.3 >=11.34 MIT
1.0 ^8.3 >=11.34 MIT
Pre-releases (3)
Version Released PHP Laravel License
0.0.3-beta ^8.3 ^11 MIT
0.0.2-beta ^8.3 ^11 MIT
0.0.1-beta ^8.3 ^11 MIT