In Sveltekit, you can only use public environment variables in client-side code. This is envorced by the name of the env var, so it needs to start with PUBLIC_.
Vercel seems to acknowlege that this is the case, and has ‘Framework Environment Variables’ versions of the System Environment Variables to facilitate this. However, for some reason, with Sveltekit chosen, the prefix is not PUBLIC_ but VITE_. Unfortunately this doesn’t work and trying to import these names from $env/static/public gives a compile error (as expected).
Current:
As described here, when the Framework Preset is set to Sveltekit, the Vercel System Variables such as VERCEL_ENV are also exposed as VITE_VERCEL_ENV. However, in order to import them, Sveltekit requires that they be prefixed with PUBLIC_ instead of VITE_.
Expected:
With Sveltekit chosen as framework, I expected the variables to have PUBLIC_ prefix such as PUBLIC_VERCEL_ENV
Deployment URL or Custom Domain:
Environment (local, preview, production):
Project Framework: Sveltekit
Build Settings:
Framework Preset:
Build Command (if not default):
Output Directory (if not default):
Install Command (if not default):
Node/Runtime Version:
Package Manager:
Relevant Packages: