Laravel Shared Data Package

Laravel Shared Data Package

Share data from your backend in JavaScript with Laravel Shared Data by Coderello. The API for this package is simple:

// Facade
    'post' => Post::first(),
    'app' => [
        'name' => config(''),
        'environment' => config('app.env'),

// Helper
    'post' => Post::first(),
    'app' => [
        'name' => config(''),
        'environment' => config('app.env'),

Which outputs data to JavaScript:

window.sharedData = {
    post: {
        content: "...",
        created_at: "...",
        // ...
    app: { /* ... */ }

To output the configured JavaScript, add the @shared directive to your views:


If you want to configure the JavaScript object, you can publish and change the configuration:


return ['js_namespace' => 'myCustomObjectName'];

This package has documentation available to help you get started, and you can view the source code on GitHub at coderello/laravel-shared-data.

Filed in: News / packages


Join 31,000+ others and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

Senior Full-Stack Engineer
[REMOTE: USA Only] All Other Applications Will be Rejected Immediately"
Senior Full Stack PHP Developer
Motto Design Studio
👉 Looking for Senior Back-End Laravel API Developer - Immediate (Full-time Contractor) 🎉
Remote // The Document Signing Experience™
Senior Full-Stack Developer
Remote, USA Only
Senior Full Stack Engineer
Remote / Los Angeles, USA
Entertainment Media