-
Install
@snowpack/plugin-dotenvnpm i --save @snowpack/plugin-dotenv -
Configure Astro via
astro.config.mjsto use@snowpack/plugin-dotenvplugins: [ "@snowpack/plugin-dotenv", ],
-
Expose Env Vars via Snowpack's
snowpack.config.mjs. Vars must be prefixed withSNOWPACK_PUBLIC_export default { env: { SNOWPACK_PUBLIC_API_BASEURL: 'https://myapi.example.org/', }, };
-
Access the Env Vars on the
__SNOWPACK_ENV__objectconst res = await fetch(`${__SNOWPACK_ENV__.SNOWPACK_PUBLIC_API_BASEURL}/events`);
Created
October 17, 2021 09:13
-
-
Save bramus/093dadabcac610c58a3e133b64f97417 to your computer and use it in GitHub Desktop.
Astro Env Vars
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment