DEV Community

Discussion on: Environment Variables in SvelteKit and Vercel

Collapse
 
danielrios549 profile image
Daniel Rios

I like this method too, the downsides is that you need to add a package for production and import dotenv/config in every single file you use it.

But the good thing is that you can still use the VITE_ prefixed variables on the client, and non-prefixed ones in the server in files files hooks and endpoints, without the client know about them.

I only think VITE shoud expose non-prefixed ones to server only automatically, and VITE_ prefixed ones to both server and client, I simply don't know why on earth this isn't the default behaviour.