coderello / laravel-shared-data
Package for sharing data from Laravel to JavaScript.
Installs: 73 432
Dependents: 1
Suggesters: 0
Security: 0
Stars: 321
Watchers: 5
Forks: 23
Open Issues: 2
Requires
- php: ^8.0
- ext-json: *
- illuminate/support: ^9.0
Requires (Dev)
- orchestra/testbench: ^7.0
- 4.0.x-dev
- 4.0.0
- 3.2.0
- 3.1.1
- 3.1.0
- 3.0.x-dev
- 3.0.0
- 2.1.0
- 2.0.x-dev
- 2.0.0
- 1.4.0
- 1.3.0
- 1.2.0
- 1.1.0
- 1.0.x-dev
- 1.0.0
- 0.2.0
- 0.1.0
- dev-hivokas-patch-1
- dev-shared-helper-function
- dev-master
- dev-directive
- dev-deep-data-conversion
- dev-deep-data-convertion
- dev-key-transformer
- dev-delayed-closures
- dev-travisci-test
This package is auto-updated.
Last update: 2024-10-22 20:17:48 UTC
README
✨ 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.