Skip to main content
Common questions and answers about using Meros for multipart response parsing.

General questions

The name meros comes from Ancient Greek μέρος (méros), meaning “part”. It reflects the library’s purpose of parsing multipart responses into individual parts.
Meros is a utility for reading multipart responses, commonly used for:
  • GraphQL @defer and @stream directives
  • Streaming responses from servers
  • File upload progress tracking
  • Any scenario where data is sent in multiple parts over HTTP
It’s particularly popular in GraphQL applications that use deferred queries to improve perceived performance.
No! Meros has zero runtime dependencies. The minified browser build is only ~642 bytes, making it extremely lightweight.
Yes. Meros is stable, well-tested, and used in production applications. It has:
  • Comprehensive test suite
  • TypeScript definitions
  • Stable API (v1.3.2)
  • Active maintenance
Meros is significantly faster than alternatives:
  • 81% faster than it-multipart in Node.js
  • 59% faster than fetch-multipart-graphql in browsers
  • Smaller bundle size
  • Zero dependencies
  • Passes all correctness tests (some competitors fail)
See the Performance page for detailed benchmarks.

Compatibility questions

Yes! Meros has dedicated browser support:
import { meros } from 'meros/browser';

const parts = await fetch('/api').then(meros);
Requirements:
  • ReadableStream support
  • TextDecoder support
  • Async iterator support
All modern browsers are supported.
Yes! Meros works with Node.js 13 and higher:
import { meros } from 'meros/node';
import http from 'http';

const response = await new Promise((resolve) => {
  const request = http.get('http://example.com/api', resolve);
  request.end();
});

const parts = await meros(response);
Absolutely! Meros includes TypeScript definitions and supports generics:
interface MyData {
  id: string;
  name: string;
}

const parts = await meros<MyData>(response);

for await (const part of parts) {
  if (part.json) {
    // part.body is typed as MyData
    console.log(part.body.id);
  }
}
Yes! Use the browser import for Deno:
import { meros } from 'https://cdn.skypack.dev/meros';
For Bun, use the standard import (Bun supports Node.js packages):
import { meros } from 'meros';

Usage questions

Meros returns the original response unchanged. This allows it to work as middleware:
const result = await meros(response);

if (result[Symbol.asyncIterator]) {
  // It's multipart
  for await (const part of result) {
    // Process parts
  }
} else {
  // It's a regular response
  const data = await result.json();
}
See the Troubleshooting guide for more details.
Check the json property on each part:
for await (const part of parts) {
  if (part.json) {
    // body is a JavaScript object
    console.log(part.body.someField);
  } else {
    // body is Buffer (Node) or string (browser)
    console.log(String(part.body));
  }
}
Meros automatically detects and parses JSON when the part has Content-Type: application/json.
Yes! Each part includes a headers object:
for await (const part of parts) {
  console.log(part.headers);
  // { 'content-type': 'application/json', ... }
}
Header names are normalized to lowercase.
The multiple option changes the yielding behavior to return arrays of parts instead of individual parts:
const chunks = await meros(response, { multiple: true });

for await (const parts of chunks) {
  // parts is an array of Part objects
  for (const part of parts) {
    // Process synchronously
  }
}
This is useful for batch operations like updating a GraphQL store, where you want to commit all parts from a chunk at once.
Yes! Meros correctly ignores:
  • Preamble: Content before the first boundary
  • Epilogue: Content after the final boundary
These are not yielded as parts, per the multipart specification.
Yes! Meros works great with RxJS:
import { from } from 'rxjs';
import { meros } from 'meros';

const parts = await fetch('/api').then(meros);

from(parts).subscribe((part) => {
  console.log(part.body);
});
Yes! Meros is designed to work with GraphQL clients like Relay that support @defer and @stream:
import { meros } from 'meros';

const parts = await fetch('/graphql', {
  method: 'POST',
  body: JSON.stringify({ query: '...' })
}).then(meros);

for await (const part of parts) {
  if (part.json) {
    // Update Relay store with incremental data
    relayEnvironment.commitPayload(operation, part.body);
  }
}

Technical questions

Meros supports any multipart/* content type:
  • multipart/mixed (most common)
  • multipart/form-data
  • Custom multipart types
For the part bodies, Meros:
  • Auto-parses application/json
  • Returns raw data (Buffer/string) for everything else
No. Nested multiparts (multipart content within multipart parts) are not currently supported.Current limitations:
  • No /alternative, /digest, or /parallel subtypes
  • No nested multipart structures
These may be added in future versions based on demand.
Meros correctly handles UTF-8, including multibyte characters split across chunks:
  • Browser: Uses TextDecoder with { stream: true }
  • Node: Uses Buffer’s built-in UTF-8 handling
Emoji, special characters, and international text work correctly.
Meros defaults to using - as the boundary if none is specified. However, this will likely fail to parse correctly.Always ensure your server sends:
Content-Type: multipart/mixed; boundary=your-boundary
Meros aims to implement RFC 1341 (The Multipart Content-Type), though it’s not yet 100% complete.Currently implemented:
  • Basic multipart parsing
  • Boundary detection
  • Header parsing
  • Preamble/epilogue handling
Not yet implemented:
  • /alternative, /digest, /parallel subtypes
  • Nested multiparts

Contributing and support

Contributions are welcome! You can:
  1. Report bugs via GitHub Issues
  2. Submit pull requests for bug fixes or features
  3. Improve documentation
  4. Share your use cases
Please review the repository’s contribution guidelines before submitting.
Meros is free to use software. If you find it valuable, you can support the author:Your support helps maintain the project!
Meros is licensed under the MIT License. You’re free to:
  • Use it commercially
  • Modify it
  • Distribute it
  • Use it privately
Just provide attribution. See the LICENSE file for details.
Yes! The library is simple and easy to alter. As the author states:
This library is simple, a mere few hundred bytes. It’s easy to copy, and easy to alter. If you do, that is fine ❤️ I’m all for the freedom of software. But please give credit where credit is due.
Please provide attribution if you use or modify the code.

Still have questions?

If your question isn’t answered here:

Build docs developers (and LLMs) love