• Stars
    star
    321
  • Rank 130,752 (Top 3 %)
  • Language
    PHP
  • License
    MIT License
  • Created almost 6 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ“ฆ An easy way to share the data from your backend to the JavaScript.

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.