Platform.js is a lightweight JavaScript library designed for comprehensive platform, browser, OS, and device detection across nearly all JavaScript environments, including browsers, Node.js, and AMD loaders. It is currently stable at version 1.3.6, with the README referencing 1.3.5. As part of the BestieJS 'Best in Class' module collection, it emphasizes solid environment support, ES5+ compatibility, and thorough testing. A key differentiator is its detailed output, providing granular information like browser name, version, layout engine, OS, and device manufacturer. However, it explicitly states it is for informational purposes only and not a substitute for robust feature detection or inference checks, which is a crucial distinction from modern approaches to browser capabilities.
npm install platformVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the library in a Node.js environment, access current platform properties, and parse a custom user-agent string.
Always use modern feature detection (e.g., `if ('serviceWorker' in navigator)`) or rely on established polyfills and transpilers for compatibility, rather than inferring capabilities from browser strings.Regularly update the `platform` package to benefit from the latest UA parsing logic. Be aware that even the latest version might not correctly identify very new or niche browsers/OSes immediately. Prioritize feature detection where possible.
When using ESM, stick to `import platform from 'platform'` (which will resolve to the CJS default export) or continue using `require('platform')`. If bundle size is a critical concern, consider alternatives that offer explicit ESM support with named exports.Ensure `<script src="platform.js"></script>` is correctly placed and accessible in your HTML (before its usage). In Node.js, verify `npm install platform` was run and the `require` path is correct. For AMD, confirm the loader configuration is correct.
Check the import/require statement. For CommonJS, `const platform = require('platform');`. For AMD, `require(['platform'], function(platform) { ... });`. In a browser, ensure the script loaded successfully and no other script overwrote the global `platform` object.Run `npm install platform` or `yarn add platform` to install the package and add it to your project's dependencies.
No dependency data recorded yet.