Customization
Customize the behavior of validation with additional options.
Below are examples of how you can customize the behavior of envin. The default values are shown in the snippets below.
Skipping validation
Skipping validation is not encouraged and will lead to your types and runtime values being out of sync. It is available to let you opt out of validation during linting (or similar), or if you're building with Docker and not all environment variables are present when building the image.
When skipping validation, the default values are still used when possible. This is useful for development environments where you want to use the default values but still have the type safety.
Custom error handling
You can customize how validation errors and invalid access attempts are handled:
Server context detection
Tell the library when we're in a server context. This is used to determine whether server-side environment variables should be accessible:
Extending presets
Your env object may extend other presets by using the extends
property. This can be used to include system environment variables for your deployment provider, or if you have a monorepo with multiple packages that share some environment variables.
envin
ships the following presets out of the box, all importable from the /presets
entrypoint:
vercel
- Vercel environment variables. See full list.neonVercel
- Neon for Vercel environment variables. See full list.uploadthing
- UploadThing environment variables. See full list.render
- Render environment variables. See full list.railway
- Railway provided system environment variables. See full list.fly
- Fly.io provided machine runtime environment variables. See full list.netlify
- Netlify provided system environment variables. See full list.upstashRedis
- Upstash Redis environment variables. See full list.coolify
- Coolify environment variables. See full list.supabaseVercel
- Supabase for Vercel environment variables. See full list.vite
- Vite environment variables. See full list.wxt
- WXT environment variables. See full list.
Feel free to open a PR with more presets!
A preset is just like any other envin configuration object, so you can easily create your own:
Custom transformations and refinements
You can use custom transformations to process environment variables or add complex validation logic: