Lets imagine that we need to handle an api public key, Laravel by default ships with an env file to set this types of properties, there are times where these values should be access from the backend and from the frontend site. Of course with InertiaJS we can set a value with key and value in the HandleInertiaRequest middleware, but it would be much cleaner to directly call these values from the ENV file through the code. Lets set an api public key as an example: Enter fullscreen mode Then in your Javascript component or any frontend file you can get the value as: console.log(import.meta.env.VITE_API_PUBLIC_KEY) Hope it helps, Happy Coding!
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners