@goenvless/env
v0.0.2
Published
The Envless runtime for applications. Loads and decrypts your environment at boot, with a typed `env` proxy, a server and client split, and Next.js, Vite and ESLint entrypoints.
Maintainers
Readme
Envless runtime
Fetches your environment from Envless when your app starts, decrypts it on the machine that runs it, and hands it to your code as a typed object. Nothing is written to disk. Variables marked server only are refused in browser code and never reach a client bundle.
Installing
npm i @goenvless/env@latestLoading at boot
node --import @goenvless/env/register server.jsNaming your variables
EnvlessServerEnv and EnvlessClientEnv ship empty, so TypeScript does not know your variable names until you generate a declaration for them. The generator lives in the CLI:
npm i -g @goenvless/cli@latest
envless typesThat writes envless-env.d.ts into the current directory. Include it in your tsconfig and every variable is typed by name.
Reading
import { env } from '@goenvless/env/server'
const db = env.DATABASE_URLimport { env } from '@goenvless/env/client'
const api = env.PUBLIC_API_URLServer variables are readable only from /server. Reading one through /client throws, and a client bundle never receives it.
Without the generated declaration, load() still hands you everything as plain strings:
import { load } from '@goenvless/env/server'
const values = await load()
const db = values.DATABASE_URLFrameworks
import { withEnvless } from '@goenvless/env/next'
export default withEnvless({})import { envless } from '@goenvless/env/vite'
export default { plugins: [envless()] }Set ENVLESS_TOKEN to a machine key and ENVLESS_PASSPHRASE or ENVLESS_KEY to decrypt. The rest, caching, typed variables, the server and client boundary and every framework recipe, lives in the documentation.
