react-native-mime-types is a focused utility for identifying and managing MIME (Multipurpose Internet Mail Extensions) types within React Native applications. It provides core functions like `lookup` to determine content types from file extensions or paths, `contentType` to construct full Content-Type headers, and `extension` to find the default file extension for a given MIME type. Unlike the general-purpose `node-mime` library, this package explicitly returns `false` for unknown types instead of providing naive fallbacks, requiring developers to implement their own fallback logic. It operates purely functionally, eschewing `new Mime()` constructors or a `.define()` API for adding custom types; all type definitions are sourced from the comprehensive `mime-db` project. The current stable version is 2.5.0, and it receives updates as needed, often reflecting changes in `mime-db`. Its primary differentiator is its simplicity and explicit behavior regarding unknown types, making it predictable for React Native environments.
npm install react-native-mime-typesVerified import paths — ran on the pinned version, not inferred.
Demonstrates common MIME type lookups by extension or path, content-type header generation, extension retrieval, and direct map access, including handling unrecognized types.
Implement custom fallback logic: `const type = mime.lookup(path) || 'application/octet-stream';`
All functions are accessed directly from the imported `mime` object (e.g., `mime.lookup()`).
To add new or custom MIME types, contribute them to the `mime-db` project, or manage a separate, custom mapping within your application code.
This library does not allow runtime definition of MIME types. Rely on `mime-db` for definitions or manage custom types manually.
Ensure the library is imported as a namespace object (ESM: `import * as mime from 'react-native-mime-types';`) or the full module object (CommonJS: `const mime = require('react-native-mime-types');`). All functions are properties of the `mime` object.No dependency data recorded yet.