Skip to content

feat: zod v4#14529

Closed
florian-lefebvre wants to merge 39 commits intonextfrom
feat/zod-4
Closed

feat: zod v4#14529
florian-lefebvre wants to merge 39 commits intonextfrom
feat/zod-4

Conversation

@florian-lefebvre
Copy link
Copy Markdown
Member

@florian-lefebvre florian-lefebvre commented Oct 13, 2025

Todo

  • experimental flag
  • public apis
    • actions
      • types
      • throw on incompatible schema version
      • runtime
    • content collections
      • types (different content typegen)
      • throw on incompatible schema version
      • runtime
    • live collections
      • types
      • throw on incompatible schema version
      • runtime
  • todos
    • error map
    • jsdoc
    • json schema upstream pr
  • cleanup
  • tests
  • docs
  • changeset
  • pr desc

Changes

Testing

Docs

@florian-lefebvre florian-lefebvre added this to the v6.0.0 milestone Oct 13, 2025
@florian-lefebvre florian-lefebvre self-assigned this Oct 13, 2025
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Oct 13, 2025

⚠️ No Changeset found

Latest commit: 099cd71

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@florian-lefebvre florian-lefebvre changed the title feat feat: zod v Oct 13, 2025
@florian-lefebvre florian-lefebvre changed the title feat: zod v feat: zod v4 Oct 13, 2025
@github-actions github-actions bot added pkg: example Related to an example package (scope) pkg: astro Related to the core `astro` package (scope) docs pr labels Oct 13, 2025
"astro": "^5.14.4",
"sharp": "^0.34.3"
"sharp": "^0.34.3",
"zod": "^4.0.0"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be removed

@riderx
Copy link
Copy Markdown
Contributor

riderx commented Oct 22, 2025

hey @florian-lefebvre if you need any help on that please share, i'm currently stuck with zod issue on build. i need zod 4 for my project but it fail as astro use v3

@florian-lefebvre
Copy link
Copy Markdown
Member Author

It may very well be possible we won't support zod 4 in Astro 6, we're still discussing it.

@riderx
Copy link
Copy Markdown
Contributor

riderx commented Oct 22, 2025

@florian-lefebvre any chance you update to v4 but still use v3 zod/v3 internally to allow us to use it in our project without breaking the build?
Right now, if I'm on my website, which uses Astro, and I update to v4 my build breaks in astro internal, which is quite annoying.

@florian-lefebvre
Copy link
Copy Markdown
Member Author

That's a good idea but we can't yet because of a bug in an upstream library: StefanTerdell/zod-to-json-schema#179

@fabien0102
Copy link
Copy Markdown

fabien0102 commented Nov 4, 2025

That's a good idea but we can't yet because of a bug in an upstream library: StefanTerdell/zod-to-json-schema#179

Somehow I was not expecting this dependency to be bumped to zod 4 since .toJSONSchema() was introduced https://zod.dev/json-schema. I moved everything I could to the native zod4 method, but maybe here this is different.

Crazy work btw, I’m not sure I would have chosen to support zod3 😅

@florian-lefebvre
Copy link
Copy Markdown
Member Author

Yes zod 4 has built-in json schema generation. But the problem here is we can't use zod/v3 on main because zod-to-json-schema doesn't support that, so users cannot use zod 4. It's a mess, we currently plan to drop support for zod 3 in v6 and only support zod 4 (plans have changed many times and may change again!)

@fabien0102
Copy link
Copy Markdown

I totally understand, supporting zod3 and zod4 add so much complexity, especially when you have crazy types built on top of it! Good luck!

For end-users, it’s actually not so hard to migrate zod3 to zod4, you can just run the codemod 😁 https://github.com/nicoespeon/zod-v3-to-v4 (I said for end user, not library author ;) )

@florian-lefebvre
Copy link
Copy Markdown
Member Author

Ha sorry I misunderstood 😆

@florian-lefebvre
Copy link
Copy Markdown
Member Author

We're not going to support both at once

@florian-lefebvre florian-lefebvre mentioned this pull request Dec 1, 2025
1 task
@controversial
Copy link
Copy Markdown

Does this PR being closed mean that Astro 6 won’t support Zod 4?

@florian-lefebvre
Copy link
Copy Markdown
Member Author

No it's just that we didn't go with this approach. This is currently being worked on at #14947

@controversial
Copy link
Copy Markdown

thanks for linking ! sorry i didn’t find that PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs pr pkg: astro Related to the core `astro` package (scope) pkg: example Related to an example package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants