stri8ed/laravel-config-js

Laravel package for exposing configs in JS

Installs: 126

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/stri8ed/laravel-config-js

v1.0.2 2024-11-20 13:52 UTC

This package is auto-updated.

Last update: 2025-12-20 16:12:57 UTC


README

A Laravel package that exposes your Laravel configuration values to JavaScript.

Installation

composer require stri8ed/laravel-config-js

Usage

In your Blade views, use the @configJs directive to expose specific config values:

@configJs('app.name')

This creates a global laravelConfig() function that you can use in JavaScript:

// Get a single config value
const appName = laravelConfig('app.name');

// With a default value
const debug = laravelConfig('app.debug', false);

You can expose multiple config values:

@configJs(['app.name', 'app.env', 'services.api.key'])

Configuration

Optionally publish the config file to customize the JavaScript function name:

php artisan vendor:publish --tag="config-js"

License

MIT