I am trying to utilise Environment variables in a svelte application.
The app is running fine on a local machine which uses a .env file but does not work when published on Netlify.(This is igonored by github)
I have added the environment variable API_KEY in the deployment section and am trying to access it using process.env.API_KEY.
i.e const ApiKey = process.env.API_KEY
I am still having difficulty using teh environment variables.
I have set a varaiable API_URL in the netlify UI and I am trying to access it using process.env.API_URL.
This results in Undefined.
Could someone advise if i am doing something wrong?
Any advice would be helpful other than to read the Support Guide which I have done but still cannot get the app to work.
It is a Svelte app built using NPM RUN BUILD
Hi, @WormCrew. The environment variables you define only exists in two places at Netlify:
in the build system during the site build
in the runtime environment of serverless functions
If there are other questions about this, please let us know.