coderello/laravel-shared-data

Package for sharing data from Laravel to JavaScript.
78,385 311
Install
composer require coderello/laravel-shared-data
Latest Version:4.0.0
PHP:^8.0
Laravel:9
Older releases:5 – 8
License:MIT
Last Updated:Feb 1, 2023
Links: GitHub  ·  Packagist
Maintainer: coderello

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 coderello/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...

644,549,754 9,698
laravel/framework

The Laravel Framework.

598,760,099 34,966
laravel/tinker

Powerful REPL for the Laravel framework.

507,193,856 7,441
laravel/serializable-closure

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

423,477,751 607
nunomaduro/collision

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

403,217,078 4,664

Version History

Version Released PHP Laravel License
4.0.0 ^8.0 ^9.0 MIT
3.2.0 ^7.3|^8.0 ^6.0|^7.0|^8.0 MIT
3.1.1 ^7.3|^8.0 ^6.0|^7.0|^8.0 MIT
3.1.0 ^7.3|^8.0 ^6.0|^7.0|^8.0 MIT
3.0.0 ^7.3 ^6.0|^7.0|^8.0 MIT