stri8ed/laravel-config-js

Laravel package for exposing configs in JS

Maintainers

Package info

github.com/stri8ed/laravel-config-js

pkg:composer/stri8ed/laravel-config-js

Statistics

Installs: 215

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

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

This package is auto-updated.

Last update: 2026-03-20 16:45:49 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