Getting Started
Installation
Version 4 requires Zod 4, zod-stream 4, and React 18.3 or React 19. react-dom is not required by this package.
Progressive hook
onReceive gets progressive raw input plus completion metadata. onEnd runs only after final Zod validation and receives z.output<T>, including completed coercions and transforms. startStream rejects on HTTP, parser, source-stream, or validation errors. Aborted streams do not call onEnd.
Framework-independent consumption
This utility has the same progressive and final-validation behavior without requiring a mounted React component.
Migration from 3.x
- Upgrade to Zod 4 and
zod-stream4. - Use React 18.3+ or React 19.
- Await
startStreamand handle rejection at the call site. - Use
onEndfor validated completion; undocumentedonComplete/onErroroptions are not part of the API.