PHPackages                             larahook/sanctum-refresh-token - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. larahook/sanctum-refresh-token

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

larahook/sanctum-refresh-token
==============================

Sanctum authentication with refresh token

v1.0.11(8mo ago)33.6kMITPHPPHP ^8.0

Since Mar 27Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/Mishanki/sanctum-refresh-token)[ Packagist](https://packagist.org/packages/larahook/sanctum-refresh-token)[ Docs](https://github.com/Mishanki/sanctum-refresh-token)[ RSS](/packages/larahook-sanctum-refresh-token/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (1)Versions (14)Used By (0)

Laravel sanctum authentication with refresh token
=================================================

[](#laravel-sanctum-authentication-with-refresh-token)

Install
-------

[](#install)

```
composer require larahook/sanctum-refresh-token

```

- Add Trait in `User` model class.

```
use Larahook\SanctumRefreshToken\Trait\HasApiTokens;

class User extends Authenticatable
{
    use HasApiTokens;
}
```

- Add `SanctumRefreshTokenServiceProvider` in `config/app.php`

```
'providers' => ServiceProvider::defaultProviders()->merge([
        //...
        EventServiceProvider::class,
        RouteServiceProvider::class,
        SanctumRefreshTokenServiceProvider::class,
    ])->toArray(),
```

Config
------

[](#config)

- You can also publish the config file to change implementations

```
php artisan vendor:publish --provider="Larahook\SanctumRefreshToken\SanctumRefreshTokenServiceProvider" --tag=config

```

Migration
---------

[](#migration)

- Install migrations

```
 php artisan vendor:publish --provider="Larahook\SanctumRefreshToken\SanctumRefreshTokenServiceProvider" --tag=migrations
 php artisan migrate

```

Usage
-----

[](#usage)

### Add trait `AuthTokens`

[](#add-trait-authtokens)

- `createTokenPair` - create `access_token` and `refresh_token`
- `refreshTokenPair` - unlink current token pair and create new `access_token` and `refresh_token`
- `logoutTokenPair` - unlink current token pair

```
use Larahook\SanctumRefreshToken\Trait\AuthTokens;

class SomeClass
{
    use AuthTokens;

    public function login(string $email, string $password, string $deviceName): array
    {
        $user = User::whereEmail($email)->first();
        // ...some login pass validation

        return $this->createTokenPair($user, $deviceName);
    }

    /**
     * @param User $user
     *
     * @return array
     */
    public function refresh(User $user): array
    {
        return $this->refreshTokenPair($user);
    }

    /**
     * @param User $user
     *
     * @return bool
     */
    public function logout(User $user): bool
    {
        return $this->logoutTokenPair($user);
    }
}
```

###  Health Score

39

—

LowBetter than 87% of packages

Maintenance61

Regular maintenance activity

Popularity24

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~39 days

Recently: every ~64 days

Total

13

Last Release

249d ago

Major Versions

v0.0.9 → v1.0.02024-03-27

PHP version history (2 changes)v0.0.9PHP ^7.4|^8.0

v1.0.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/5513299b5470b3e7c5f0582ce7a7f941528a3ad48321429e375f1645d28a389e?d=identicon)[Mishanki](/maintainers/Mishanki)

---

Tags

automationrefreshsanctumtokenlaravelAuthenticationsanctumrefresh-token

### Embed Badge

![Health badge](/badges/larahook-sanctum-refresh-token/health.svg)

```
[![Health](https://phpackages.com/badges/larahook-sanctum-refresh-token/health.svg)](https://phpackages.com/packages/larahook-sanctum-refresh-token)
```

###  Alternatives

[hasinhayder/tyro

Tyro - The ultimate Authentication, Authorization, and Role &amp; Privilege Management solution for Laravel 12

6641.4k1](/packages/hasinhayder-tyro)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
