cross-env, you will not have to do anything special in Frontity. You just need to add it to your
dotenvwe must create a
client.jsfiles (that will each only be executed in the appropriate environment), we are therefore able to privately access the content of the environment variable on the server (for example to perform a request to an external API and storing this data in the
stateso it can be accessed from your React components).
server.jsfile could be something like this:
API_TMDBenvironment variable is defined in a
.envfile included in that project
beforeSSRdefined in the
server.js) will ensure that your API credentials are secure (i.e. they will not be part of the client bundle) and are only visible to the code running server-side. However, remember to take into account that this logic will be executed in the initialization (or bootstrapping) of the Frontity app (i.e. for any page loaded the first time).
frontity.settings.jsor your package
statefor that, whichever is more appropriate for your situation.
stateand it will be sent to the client for the React hydration.