JS Shared Data
This package provides a front-end solution for the coderello/laravel-shared-data
package.
Install
yarn add js-shared-data
Usage
Let's imagine that we shared such data from the backend using coderello/laravel-shared-data
:
share([ 'user' => [ 'full_name' => 'Ilya Sakovich', 'username' => 'hivokas', 'email' => 'me@hivokas.com', ], 'balance' => 120,]);
On the front-end side we can access this data using shared()
helper.
; // retrieve the user objectconst user = ; // retrieve the username from the user objectconst username = ; // retrieve the balanceconst balance = ; // specify the default value which will be used if value for specified path doesn't existconst status = ;
Customization
; // specify the default value globallysharedData; // specify the namespace which contains an object with all shared datasharedData; // specify the sourcesharedData;