@tokengate/env-vite
v0.2.1
Published
Tokengate environment variable integration for Vite
Downloads
22
Maintainers
Readme
@tokengate/env-vite
Tokengate environment variable integration for Vite.
Encrypted, type-safe env vars injected at dev and build time.
Install
npm install @tokengate/env-vite @tokengate/envUsage
// vite.config.ts
import { defineConfig } from 'vite'
import { tokengate } from '@tokengate/env-vite'
export default defineConfig({
plugins: [
tokengate({
schema: {
VITE_API_URL: { type: 'url', required: true },
VITE_APP_NAME: { type: 'string', default: 'My App' },
DATABASE_URL: { type: 'string', required: true, sensitive: true },
}
})
]
})How it works
- Variables prefixed with
VITE_are injected intoimport.meta.env(client-safe) - All variables are injected into
process.env(server-side / SSR) - Environment auto-detected from Vite's
mode(development,production, etc.) - Values fetched from Tokengate cloud, decrypted locally, validated against schema
- Falls back to
.envfiles andprocess.env
Options
tokengate(config, {
clientPrefix: 'VITE_', // Prefix for client-exposed vars (default: "VITE_")
})License
MIT
