X
Xata2mo ago
dream

Custom env variable names

Hello! I'm using a vite plugin to check for environment variables before creating a new build. Vite recommends declaring env variable names with the prefix VITE_. The plugin only detects variables with this prefix. How can I configure the xata SDK and CLI to use the env variables VITE_XATA_BRANCH and VITE_XATA_API_KEY?
3 Replies
kostas
kostas2mo ago
See the example here about initializing a Xata SDK client with VITE env vars: https://xata.io/docs/getting-started/sveltekit#query-and-list-the-posts
Get started with SvelteKit and Xata
Get started with SvelteKit and Xata
kostas
kostas2mo ago
Basically, "getXataClient" defaults to XATA_BRANCH and XATA_APIKEY. But "XataClient" is configurable with apiKey and branch as parameters. As for the CLI, I don't believe there is a way to use VITE variables for it,as the env vars it looks for are hardcoded. But that shouldn't be an issue as the CLI runs standalone, so it can use the XATA vars.
dream
dream2mo ago
Thanks, I hadn't seen that 👍
Want results from more Discord servers?
Add your server