matchmediaquery is an open-source JavaScript library providing isomorphic media query functionality, allowing developers to check CSS media queries both in browser environments and server-side contexts. Originally forked from the `matchmedia` project due to its maintainer's publishing delays, this library aimed to provide an active alternative. However, its last stable version (0.4.2) was published in late 2015, and the project has seen no significant updates or maintenance since. As a result, it is considered abandoned and may not be suitable for modern web development, lacking support for contemporary JavaScript module systems (ESM), TypeScript definitions, or up-to-date media query specifications. Its primary differentiator was its isomorphic capability, which is now often handled by more modern, actively maintained libraries or frameworks.
npm install matchmediaqueryVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import and use `matchmediaquery` to evaluate media queries, including server-side simulation of viewport properties.
Migrate to a modern, actively maintained library for isomorphic media queries or use client-side `window.matchMedia` directly for browser contexts. Consider libraries like `react-responsive` (for React) or custom solutions.
Ensure your environment supports CommonJS `require()` or configure your bundler (e.g., Webpack, Rollup) to correctly transpile CJS modules. In Node.js, use `const matchMediaQuery = require('matchmediaquery');`Create a custom declaration file (e.g., `matchmediaquery.d.ts`) to provide type information. Example: `declare module 'matchmediaquery' { function matchMediaQuery(query: string, options?: object): boolean; export = matchMediaQuery; }`Always provide a comprehensive set of viewport and device-specific options (e.g., `width`, `height`, `type`, `devicePixelRatio`) when using `matchMediaQuery` in a server-side context to ensure accurate simulation of the target environment.
For CommonJS-only libraries, ensure your project's `package.json` does NOT have `"type": "module"` if you are using `require()`. If your project is ESM-native, you might need to use dynamic `import('matchmediaquery')` or resort to a bundler to handle CJS modules.Import the library as a default CommonJS export: `const matchMediaQuery = require('matchmediaquery');` if in a CJS context. If using a bundler with ESM, ensure it correctly handles CJS default exports.Create a manual type declaration file (e.g., `global.d.ts` or `matchmediaquery.d.ts`) in your project. Add `declare module 'matchmediaquery' { function matchMediaQuery(query: string, options?: object): boolean; export = matchMediaQuery; }` to define its interface.No dependency data recorded yet.