zod-config weekly downloads statistics
By alexmarqs · npm · Vite plugins
Load configuration variables from multiple sources with flexible adapters, ensuring type safety with Zod.
zod-config has 17,074 recorded weekly downloads on npm, an increase of 25.5% over the past 30 days, ranking #1087 of 3,247 tracked listings.
About zod-config
Zod Config
Load configuration variables from multiple sources type safely using Zod.
The new major version supports both Zod 4 and Zod 3 out of the box. Check the compatibility section for more details.
Features
- 👮♂️ Type safety. Zod Config uses Zod;
- 🤌 Tiny. Zod Config is a tiny library with no dependencies, tree-shaking friendly;
- ✨ Flexible. Combine multiple adapters to load the configuration from different sources. We deeply merge the configuration from different sources, following the order of the adapters provided; Create your own adapters easily; Use the callback functions to handle errors and success due to the async nature of the adapters;
- 🪴 Easy to use. Zod Config is designed to be easy to use, with a simple API;
- 🔄 Async / Sync support. Zod Config provides both asynchronous and synchronous APIs to fit different application needs;
- ▲ Next.js, Vite, Astro, TanStack Start. Type-safe environment variables with server and client schemas, checked when the build starts;
Install
npm install zod-config zod # npm
pnpm add zod-config zod # pnpm
yarn add zod-config zod # yarn
Table of contents:
- Quick Start
- Compatibility
- Basic Usage
- Built In Adapters
- Type-safe Environment Variables
- Advanced Features
- Contributing notes
- On the web
Quick Start
Zod Config provides both asynchronous and synchronous APIs for loading configuration:
loadConfig: Asynchronous function that takes a Zod Object schema and returns a promise resolving to the validated configuration object;loadConfigSync: Synchronous version that takes the same configuration but returns the result directly without a promise;
Note:
loadConfigSynconly supports synchronous adapters and schemas. For details on compatibility, see Synchronous loading.
Here are the available configuration options:
Here are the available configuration options for loadConfig and loadConfigSync:
| Property | Type | Description | Required | Global | Adapter |
|---|---|---|---|---|---|
schema | AnyZodObject | A Zod Object schema to validate the configuration. | ✅ | N/A | N/A |
adapters | Array<Adapter | SyncAdapter> | Adapter | SyncAdapter | Adapter(s) to load the configuration from. If not provided, process.env will be used. | ❌ | N/A | N/A |
onError | (error: InferredErrorConfig<T>) => void) | A callback to be called when an error occurs. | ❌ | ✅ | ❌ |
onSuccess | (data: InferredDataConfig<S>) => void | A callback to be called when the configuration is loaded successfully. | ❌ | ✅ | ❌ |
logger | Logger | A custom logger to be used to log messages. By default, it uses console. | ❌ | ✅ | ❌ |
keyMatching | 'strict' | 'lenient' | How to match keys between the schema and the data of the adapters. By default, it uses strict. | ❌ | ✅ | ✅ |
silent | boolean | Whether to suppress errors. By default, it is false. | ❌ | ✅ | ✅ |
transform | (obj: { key: string; value: unknown }) => { key: string; value: unknown } | false | Function to transform key-value pairs before processing. If the function returns false, the key-value pair will be dropped. | ❌ | ✅ | ✅ |
Note: Options marked as both "Global" and "Adapter" can be set at the global level (affecting all adapters) or at individual adapter level (affecting only that adapter). When both are provided, the adapter-level option takes precedence. For specific adapter options, check the section of the adapter you are using.
From the package we also expose the necessary types in case you want to use them in your own adapters. Some of the options are shared between the global config and the adapter config, so you can use them in your own adapters as well.
This library provides some built in adapters to load the configuration from different sources via modules. You can easily import them from zod-config/<built-in-adapter-module-name>.
Compatibility
Zod Config supports both Zod 4 and Zod 3 out of the box. To start using it, just make sure you have the correct versions of zod-config (zod-config@^1.0.0) and zod (zod@^3.25.1 or zod@^4.0.0)!
[!WARNING] Zod 3 support is deprecated and will be removed in the next major version. Use Zod 4 or Zod 4 Mini for new code.…
Description from the npm listing.
- zod
- config
- env
- json
- json5
- yaml
- toml
- dotenv
- typescript
- nextjs
- vite
- vite-plugin
- astro
- tanstack-start
- environment-variables
- secrets
- adapters
- typesafe
- aws
- secrets-manager
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (128)Similar npm Vite plugins plugins
All 20 zod-config alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/zod-config. First seen Nov 23, 2026; last successful collection Dec 6, 2026. See the methodology.