Installation
Requirements
Before installing zod
, make sure your environment meets the following requirements:
- TypeScript
4.5+
(Recommended for type safety and best performance). - Enable
strict
mode in yourtsconfig.json
(Best practice for TypeScript projects).
TypeScript Configuration
Modify your tsconfig.json
to enable strict mode:
{
"compilerOptions": {
"strict": true
}
}
Via Package Managers
To install zod
in your project, use one of the following package managers:
Canary Version
Zod also publishes a canary
version on every commit. To install the canary:
The rest of this README assumes you are using npm and importing directly from the
"zod"
package.
Using a CDN
For quick usage in the browser without installing dependencies, you can include zod
from a CDN:
UMD (Global Script)
<!-- Load the minified version from jsDelivr -->
<script src="https://cdn.jsdelivr.net/npm/zod@latest/lib/index.min.js"></script>
ESM (Module Import)
<script type="module">
import zod from "https://cdn.jsdelivr.net/npm/zod@latest/+esm";
</script>
Note:
- The UMD version loads
zod
as a global variable. - The ESM version allows importing as a module in modern browsers.
Now you are ready to start using zod! 🚀