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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners