larajax/larajax

A small AJAX framework for Laravel, built to bring simplicity back to Laravel development.

Maintainers

Package info

github.com/larajax/larajax

Homepage

Language:JavaScript

pkg:composer/larajax/larajax

Statistics

Installs: 18 247

Dependents: 1

Suggesters: 0

Stars: 32

Open Issues: 1

v2.1.0 2026-03-20 09:03 UTC

README

Larajax

Larajax is a small AJAX framework for Laravel that keeps interactions inside controllers and responses.

It is designed for developers who like HTML-over-the-wire patterns, but want to stay close to Laravel’s normal request → controller → response flow, without building APIs or managing frontend state.

About Larajax

Larajax lets you define AJAX handlers directly in Laravel controllers and trigger them from HTML using data-request attributes.

No API routes. No fetch wiring. No frontend state layer.

// One route, multiple handlers
Route::any('/profile', [ProfileController::class, 'index']);

class ProfileController extends LarajaxController
{
    // Page Action
    public function index()
    {
        return view('pages.profile');
    }

    // AJAX Handlers
    public function onSave()
    {
        request()->validate([
            'first_name' => 'required'
        ]);

        // Return targeted DOM updates
        return ajax()->update([
            '#message' => "Save complete!"
        ]);
    }

    public function onDelete()
    {
        // ...
    }
}
<!-- View -->
<form>
    <input name="first_name" />

    <button data-request="onSave">
        Save!
    </button>
</form>

<div id="message"></div>

One route can expose multiple interaction handlers without splitting logic across endpoints.

Key ideas

  • Controller-based AJAX handlers
  • HTML as the source of truth
  • Targeted DOM updates
  • Standard Laravel validation and CSRF handling
  • Optional reusable component system

Installation

Install the backend package:

composer require larajax/larajax

Install the frontend helper:

npm install larajax

Then import and initialize in your JavaScript entry file:

import { jax } from 'larajax';
window.jax = jax;
jax.start();

Background

Larajax was extracted from the AJAX framework used in October CMS and has been running in production applications for several years.

It is now packaged as a standalone Laravel library.

Resources

License

Larajax is open-sourced software licensed under the MIT license.