PHPackages                             pristavu/momentum-lock - 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. [Caching](/categories/caching)
4. /
5. pristavu/momentum-lock

ActiveLibrary[Caching](/categories/caching)

pristavu/momentum-lock
======================

0.4.1(9mo ago)045MITPHPPHP ^8.2CI passing

Since Sep 12Pushed 9mo agoCompare

[ Source](https://github.com/pristavu/momentum-lock)[ Packagist](https://packagist.org/packages/pristavu/momentum-lock)[ GitHub Sponsors](https://github.com/lepikhinb)[ RSS](/packages/pristavu-momentum-lock/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (9)Versions (3)Used By (0)

Momentum Lock
=============

[](#momentum-lock)

Momentum Lock is a Laravel package that lets you handle Laravel authorizations on the frontend level.

The package is only intended to work with [Laravel Data](https://github.com/spatie/laravel-data) objects and [TypeScript Transformer](https://github.com/spatie/laravel-typescript-transformer).

- [**Installation**](#installation)
    - [**Laravel**](#laravel)
    - [**Frontend**](#frontend)
- [**Usage**](#usage)
- [**Advanced Inertia**](#advanced-inertia)
- [**Momentum**](#momentum)

Installation
------------

[](#installation)

### Laravel

[](#laravel)

Install the package into your Laravel app.

```
composer require based/momentum-lock
```

### Frontend

[](#frontend)

The frontend package is framework-agnostic and will work great within any TypeScript-powered workflow.

Install the [frontend package](https://github.com/lepikhinb/momentum-lock-helper).

```
npm i momentum-lock
# or
yarn add momentum-lock
```

Usage
-----

[](#usage)

Extend your data classes from `DataResource` instead of `Data` provided by [Laravel Data](https://github.com/spatie/laravel-data).

```
use Momentum\Lock\Data\DataResource;

class UserData extends DataResource
{
    public function __construct(
        public int $id,
        public string $username
    ) {
    }
}
```

You can either specify the list of abilities manually, or let the package resolve them from the corresponding policy class.

```
class UserData extends DataResource
{
    protected $permissions = ['update', 'delete'];
}
```

Register `DataResourceCollector` in the TypeScript Transformer configuration file — `typescript-transformer.php`. This class helps TypeScript Transformer handle `DataResource` classes and append permissions to generated TypeScript definitions.

```
return [
    'collectors' => [
+       Momentum\Lock\TypeScript\DataResourceCollector::class,
        Spatie\TypeScriptTransformer\Collectors\DefaultCollector::class,
        Spatie\LaravelData\Support\TypeScriptTransformer\DataTypeScriptCollector::class,
    ],
]
```

On the frontend, you can use the helper `can`. This function checks whether the required permission is set to true on the passed object, and can be used in both scripts or templates.

```

import { can } from "momentum-lock"

const props = defineProps()

     Edit

```

Advanced Inertia
----------------

[](#advanced-inertia)

[![](https://camo.githubusercontent.com/6d303aa5ddd234c4e468400424ebf0c4267e6c5dba44e51f96dec88dc6e8b29f/68747470733a2f2f616476616e6365642d696e65727469612e636f6d2f6f672e706e67)](https://advanced-inertia.com)

Take your Inertia.js skills to the next level with my book [Advanced Inertia](https://advanced-inertia.com/). Learn advanced concepts and make apps with Laravel and Inertia.js a breeze to build and maintain.

Momentum
--------

[](#momentum)

Momentum is a set of packages designed to improve your experience building Inertia-powered apps.

- [Modal](https://github.com/lepikhinb/momentum-modal) — Build dynamic modal dialogs for Inertia apps
- [Preflight](https://github.com/lepikhinb/momentum-preflight) — Realtime backend-driven validation for Inertia apps
- [Paginator](https://github.com/lepikhinb/momentum-paginator) — Headless wrapper around Laravel Pagination
- [Trail](https://github.com/lepikhinb/momentum-trail) — Frontend package to use Laravel routes with Inertia
- [Lock](https://github.com/lepikhinb/momentum-lock) — Frontend package to use Laravel permissions with Inertia
- [Layout](https://github.com/lepikhinb/momentum-layout) — Persistent layouts for Vue 3 apps
- [Vite Plugin Watch](https://github.com/lepikhinb/vite-plugin-watch) — Vite plugin to run shell commands on file changes

Credits
-------

[](#credits)

- [Boris Lepikhin](https://twitter.com/lepikhinb)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance57

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 72.2% of commits — single point of failure

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 ~0 days

Total

2

Last Release

287d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2875b9ef72b09212f72a878c4eb30c237ad1adf460ddd1a1f376ef7d4090f83e?d=identicon)[pristavu](/maintainers/pristavu)

---

Top Contributors

[![lepikhinb](https://avatars.githubusercontent.com/u/17538801?v=4)](https://github.com/lepikhinb "lepikhinb (13 commits)")[![pristavu](https://avatars.githubusercontent.com/u/4123729?v=4)](https://github.com/pristavu "pristavu (2 commits)")[![raymondmuller](https://avatars.githubusercontent.com/u/3808818?v=4)](https://github.com/raymondmuller "raymondmuller (1 commits)")[![ycs77](https://avatars.githubusercontent.com/u/38133356?v=4)](https://github.com/ycs77 "ycs77 (1 commits)")[![Yiddishe-Kop](https://avatars.githubusercontent.com/u/36875437?v=4)](https://github.com/Yiddishe-Kop "Yiddishe-Kop (1 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/pristavu-momentum-lock/health.svg)

```
[![Health](https://phpackages.com/badges/pristavu-momentum-lock/health.svg)](https://phpackages.com/packages/pristavu-momentum-lock)
```

###  Alternatives

[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k8.7M64](/packages/spatie-laravel-responsecache)[illuminate/cache

The Illuminate Cache package.

12936.5M1.7k](/packages/illuminate-cache)[iazaran/smart-cache

Smart Cache is a caching optimization package designed to enhance the way your Laravel application handles data caching. It intelligently manages large data sets by compressing, chunking, or applying other optimization strategies to keep your application performant and efficient.

2119.7k](/packages/iazaran-smart-cache)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[wearepixel/laravel-cart

A cart implementation for Laravel

1355.6k](/packages/wearepixel-laravel-cart)

PHPackages © 2026

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