lenius/laravel-shared-data

Package for sharing data from Laravel to JavaScript.
2,868
Install
composer require lenius/laravel-shared-data
Latest Version:v1.0.1
PHP:^8.0
Laravel:9 · 10 · 11
License:MIT
Last Updated:Apr 4, 2025
Links: GitHub  ·  Packagist
Maintainer: lenius

Laravel Shared Data

✨ Introduction

Laravel Shared Data provides an easy way to share the data from your backend to the JavaScript.

🚀 Quick start

  • Install the package

    composer require lenius/laravel-shared-data
    
  • Include the @shared directive into your blade layout before all scripts.

  • Share the data from within Laravel:

    share(['user' => $user, 'title' => $title]);
    
  • Access the data from the JavaScript directly:

    const user = window.sharedData.user;
    const title = window.sharedData.title;
    
  • Or using the built-it global helper:

    const user = shared('user');
    const title = shared('title');
    

📖 License

Laravel Shared Data is open-sourced software licensed under the MIT license.

Related Packages

doctrine/dbal

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

641,106,524 9,700
laravel/framework

The Laravel Framework.

593,882,149 34,959
laravel/tinker

Powerful REPL for the Laravel framework.

502,645,077 7,441
laravel/serializable-closure

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

418,291,778 609
nunomaduro/collision

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

394,964,158 4,660

Version History

Version Released PHP Laravel License
v1.0.1 ^8.0 ^9.0|^10|^11 MIT
v1.0.0 ^8.0 ^9.0|^10 MIT