Skip to content

Zod dependency configuration does not follow official best practices for library authors #982

Description

@Areo-Joe

Zod dependency configuration does not follow official best practices for library authors

Summary

The current Zod usage in AG-UI TypeScript SDK does not follow the official Zod best practices for library authors. This may cause version conflicts for users and lacks Zod 4 compatibility.

Current State

1. Dependency Configuration Issues

Zod is currently in dependencies instead of peerDependencies:

Package Current Config Issue
@ag-ui/core dependencies: "zod": "^3.22.4" ❌ Should be peerDependencies
@ag-ui/client dependencies: "zod": "^3.22.4" ❌ Should be peerDependencies
@ag-ui/vercel-ai-sdk dependencies: "zod": "^3.22.4" ❌ Should be peerDependencies

According to official docs:

Any library built on top of Zod should include "zod" in "peerDependencies". This lets your users "bring their own Zod".

2. Outdated Version Range

Current version ^3.22.4 is outdated and doesn't support Zod 4.

Recommended version range:

{
  "peerDependencies": {
    "zod": "^3.25.0 || ^4.0.0"
  }
}

3. Import Path Not Using Permalinks

All files currently import Zod like this:

import { z } from "zod";  // ❌ Not recommended

Official recommendation:

Import from these subpaths only. Think of them like "permalinks" to their respective Zod versions.

  • "zod/v3" for Zod 3 ✅
  • "zod/v4/core" for the Zod 4 Core package ✅
import * as z3 from "zod/v3";  // ✅ Recommended

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions