T
TanStack7mo ago
wise-white

Accessing env vars in the client

Is there a way to access an env var (parsed via process.env in the client? It's a CLIENT_ID that I need to share between client and server. If I import it directly and/or pass it to the client via loader data I receive some weird errors probably caused by tree shaking removing those variables.
2 Replies
rival-black
rival-black7mo ago
import.meta.env and they must start with VITE_ to be available to the client You can modify that prefix if you want
wise-white
wise-whiteOP7mo ago
Right, I forgot that was a thing. Thanks 🙏

Did you find this page helpful?