{"library":"react-native-mime-types","title":"MIME Types Utility for React Native","description":"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.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install react-native-mime-types"],"cli":null},"imports":["import * as mime from 'react-native-mime-types';","const mime = require('react-native-mime-types');","import * as mime from 'react-native-mime-types';\nmime.lookup('file.json');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import * as mime from 'react-native-mime-types';\n\nconsole.log('--- MIME Type Lookups ---');\nconsole.log('JSON file type:', mime.lookup('json')); // 'application/json'\nconsole.log('Markdown file type:', mime.lookup('.md')); // 'text/x-markdown'\nconsole.log('HTML file type:', mime.lookup('file.html')); // 'text/html'\nconsole.log('JavaScript file type:', mime.lookup('folder/file.js')); // 'application/javascript'\nconsole.log('Unrecognized file type (should be false):', mime.lookup('cats')); // false\n\nconsole.log('\\n--- Content-Type Header Creation ---');\nconsole.log('Markdown content type header:', mime.contentType('markdown')); // 'text/x-markdown; charset=utf-8'\nconsole.log('JSON content type header:', mime.contentType('file.json')); // 'application/json; charset=utf-8'\n\nconsole.log('\\n--- Extension Lookup ---');\nconsole.log('Extension for octet-stream:', mime.extension('application/octet-stream')); // 'bin'\n\nconsole.log('\\n--- Direct Maps ---');\nconsole.log('Type for .txt:', mime.types['txt']); // 'text/plain'\nconsole.log('Extensions for text/html:', mime.extensions['text/html']); // ['html', 'htm']","lang":"typescript","description":"Demonstrates common MIME type lookups by extension or path, content-type header generation, extension retrieval, and direct map access, including handling unrecognized types.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}