Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/coderello/laravel-shared-data
📦 An easy way to share the data from your backend to the JavaScript.
https://github.com/coderello/laravel-shared-data
Last synced: about 2 months ago
JSON representation
📦 An easy way to share the data from your backend to the JavaScript.
- Host: GitHub
- URL: https://github.com/coderello/laravel-shared-data
- Owner: coderello
- License: mit
- Created: 2019-03-18T21:03:13.000Z (over 5 years ago)
- Default Branch: 4.0
- Last Pushed: 2023-02-01T23:40:23.000Z (over 1 year ago)
- Last Synced: 2024-04-26T00:42:38.248Z (5 months ago)
- Language: PHP
- Homepage: https://coderello.com/docs/laravel-shared-data/1.0/sharing-data
- Size: 672 KB
- Stars: 324
- Watchers: 5
- Forks: 20
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# 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:
```bash
composer require coderello/laravel-shared-data
```- Include the `@shared` directive into your blade layout before all scripts.
- Share the data from within Laravel:
```bash
share(['user' => $user, 'title' => $title]);
```
- Access the data from the JavaScript directly:
```bash
const user = window.sharedData.user;
const title = window.sharedData.title;
```
- Or using the built-it global helper:
```bash
const user = shared('user');
const title = shared('title');
```## 📖 License
**Laravel Shared Data** is open-sourced software licensed under the [MIT license](LICENSE.md).