Secret token to javascript

How can be set a secret token to use it in javascript routes without submitting it to GIT repo?

Something like



For secrets like ACF PRO key, Google Maps key and others I use for development the .env file and for Trellis the vault.yml.

Yes, thank you. I’m not sure if my question is right. With .env variables I can make them available to PHP, not for JS. Isn’t it?

You can get the environment variable and pass it as JavaScript variable either in the theme or in a pugin.

1 Like

This topic was automatically closed after 42 days. New replies are no longer allowed.