Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

m615's avatar
Level 2

How do I access .env vars from a custom Nova component

I'm creating a custom field component. I will need to access an env variable from my Vue component. I've tried to access using process like so proccess.env.MIX_MY_VAR However I get a javascript error that env is undefined.

0 likes
3 replies
martinbean's avatar

@m615 Environment variables are only added to process.env object when building the JavaScript file. So if you’re writing a JavaScript component, building it, then installing it various Nova installations, it’ll only have access to what was provided at build time. It can’t access server environment stuff after that.

If it could, that would be a massive security hole if a JavaScript file running in the browser could just start randomly reading environment variables from the server containing sensitive information like API keys, database credentials, etc.

m615's avatar
Level 2

Totally understand that however, what I'm asking is how can I access .env in my Nova field the same way I'm able to in a regular Laravel / Vue project.

Please or to participate in this conversation.