What is Meros?
Meros is a lightweight utility library that simplifies reading multipart responses in both browser and Node.js environments. At just 642 bytes, it provides a seamless API for consuming multipart/mixed responses through async generators. The name meros comes from Ancient Greek μέρος (méros), meaning “part”.Quick installation
Install Meros via npm, pnpm, or yarn in seconds
Get started
Start reading multipart responses in minutes
API reference
Explore the complete API documentation
Examples
Learn from real-world usage examples
Key features
Zero dependencies
No external dependencies means a smaller bundle size and faster installation
Universal support
Works seamlessly in both browser and Node.js environments
High performance
Outperforms alternatives by up to 1.8x in benchmarks
Type safe
Full TypeScript support with generic types for response bodies
Automatic JSON parsing
Automatically detects and parses JSON content-type parts
Framework agnostic
Integrates with any framework - works with Relay, RxJS, and more
Why Meros?
Multipart responses are commonly used for streaming data, particularly with GraphQL@defer and @stream directives. However, parsing these responses manually can be error-prone and complex. Meros handles all the complexity for you:
- Automatic boundary detection: Parses the boundary from content-type headers
- Stream processing: Efficiently processes chunks as they arrive
- Smart parsing: Automatically parses JSON when detected, falls back to raw strings/buffers
- Preamble/epilogue handling: Correctly ignores multipart preamble and epilogue sections
- Multiple modes: Support for both single-part and multi-part yielding strategies
Meros implements the RFC1341 multipart standard, though some advanced features like nested multiparts and alternative/digest/parallel subtypes are not yet supported.
How it works
Meros takes a response object and returns either:- The original response (if it’s not multipart)
- An async generator that yields parsed parts (if it’s multipart/mixed)
body: The parsed content (JSON object or string/Buffer)headers: Key-value pairs of all headers from that partjson: Boolean indicating whether the body was parsed as JSON
Use cases
- GraphQL streaming: Handle
@deferand@streamdirective responses - Progressive data loading: Display data as it arrives rather than waiting for complete responses
- File uploads: Process multipart form data streams
- Real-time updates: Stream server-sent data chunks to the client
- Incremental rendering: Render UI components as their data becomes available
Next steps
Install Meros
Add Meros to your project using your preferred package managerGo to installation →
Try the quickstart
Follow our quickstart guide to read your first multipart responseGo to quickstart →
Explore the API
Learn about all available options and typesGo to API reference →