devloco / create-react-wptheme

Create modern, React-enabled WordPress themes with a single command.
MIT License
360 stars 61 forks source link

Environment variable #63

Open believelody opened 3 years ago

believelody commented 3 years ago

Hi, I've just discovered your library and it's awesome. I come from frontend world so I don't know so much about wordpress and php. I want to use environment variables. In a standalone react app, I've just to create a .env file at root folder and set a variable prefixed by REACTAPP. How can I do it with your react theme within wordpress app ? The standalone way doesn't work.

sanion commented 1 year ago

Hi @believelody . I was also thinking about this issue and I think the best way to archive this would be in the backend, with php and send all your data with api to the front end. Here is good article : https://erikpoehler.com/2020/12/30/using-an-env-file-for-database-and-other-credentials/