Lightweight browser, device & network detection library
aki-info-detect is a modern, lightweight JavaScript library that provides comprehensive device, browser, and system information detection for web applications. Built with performance and developer experience in mind, it leverages modern browser APIs including the Client Hints API for accurate hardware detection while maintaining a minimal footprint (~3.8 kB gzipped).
Whether you need to customize user experiences based on device capabilities, gather analytics data, or implement platform-specific features, aki-info-detect provides a unified, easy-to-use API that works seamlessly across all modern browsers.
npm install aki-info-detect and start detecting in seconds!
Browser, OS, CPU, GPU, RAM, network, battery, and more from a single library
Minimal bundle size with tree-shakeable exportsโimport only what you need
Built on modern Web APIs with graceful fallbacks for older browsers
Advanced detection for Apple M-series chips (M1, M2, M3, M4, and beyond)
Implements caching for network requests to minimize external API calls
No external runtime dependenciesโjust pure, optimized JavaScript
Dynamically adjust your UI based on device capabilities and screen properties:
const info = await akiInfoDetect();
if (info.isMobile) {
loadMobileUI();
} else if (info.RAM < 4) {
enableLowMemoryMode();
}
Gather detailed technical data to understand your user base:
const info = await akiInfoDetect();
analytics.track('page_view', {
browser: info.browser,
os: info.os.string,
device: info.isMobile ? 'mobile' : 'desktop',
gpu: info.GPU
});
Enable or disable features based on browser capabilities:
const info = await akiInfoDetect();
const chromeVersion = parseInt(info.browser.split(' ')[1]);
if (info.browser.includes('Chrome') && chromeVersion >= 90) {
enableAdvancedFeatures();
}
Optimize content delivery based on hardware capabilities:
const info = await akiInfoDetect();
if (info.CPU === 'Apple Silicon') {
loadWebPImages();
} else if (info.GPU.includes('NVIDIA')) {
enableHardwareAcceleration();
}
Adapt content loading strategies based on connection quality:
const info = await akiInfoDetect();
const conn = info.getConnection();
if (conn.type === '4g' && conn.downlink > 5) {
loadHDContent();
} else {
loadCompressedContent();
}
aki-info-detect stands out from other detection libraries with its modern approach and comprehensive feature set:
| Feature | aki-info-detect | Platform.js | UA-Parser.js | Detect.js |
|---|---|---|---|---|
| Bundle Size (gzipped) | ~3.8 kB | ~2.5 kB | ~9 kB | Varies |
| Client Hints API | โ | โ | โ | โ |
| GPU Detection | โ | โ | โ | โ |
| Apple Silicon Detection | โ (M1-MX) | โ | โ | โ |
| Network Info (IP/ISP) | โ | โ | โ | โ |
| Battery & Geolocation | โ | โ | โ | โ |
| Tree-shakeable | โ | โ ๏ธ | โ ๏ธ | โ ๏ธ |
| TypeScript Support | โ Full | โ ๏ธ Community | โ | โ |
| Active Maintenance | โ | โ ๏ธ | โ | โ Archived |
All modern browsers with ES2020+ support: Chrome/Edge 89+, Firefox 88+, Safari 14+, Opera 76+. Client Hints features work best in Chromium-based browsers.
No, aki-info-detect is specifically designed for browser environments. It relies on browser APIs like navigator, screen, and Web APIs that are not available in Node.js.
Very accurate for modern browsers that support Client Hints API. For browsers without Client Hints, it falls back to user agent parsing which is still reliable but less detailed. GPU and CPU detection is most accurate in Chromium-based browsers.
While user agents can be spoofed, Client Hints API provides more reliable detection. For critical functionality, always combine with feature detection rather than relying solely on browser/platform detection.
No. The library only detects information locally in the browser. The optional network info feature (getNetworkInfo()) makes a request to a public IP API, but this is only triggered when you explicitly call that method.
aki-info-detect is privacy-conscious. Network requests are cached for 1 hour to minimize external API calls, and all detection happens client-side. No data is sent to our servers.
Detection of browser/device information is generally considered functional data necessary for website operation. However, always review your local regulations and privacy policies, especially when using geolocation or storing detected data.
The Client Hints API requires the server to explicitly request detailed information via Accept-CH headers. Without these headers, browsers will only provide basic user agent data. This is a browser security feature designed to enhance user privacy.
Absolutely! aki-info-detect is framework-agnostic. Check the Documentation tab for React Hook and Vue Composable examples.
Use tree-shakeable imports to include only the functions you need:
import { detectBrowser, detectOS } from 'aki-info-detect';
Yes, full TypeScript declarations are included in the package.
Network info (IP, ISP, country) is cached for 1 hour by default. You can force a refresh by passing true to getNetworkInfo(true).
Make sure your server is configured to send the required Accept-CH headers. Without these headers, detailed Client Hints data won't be available. Check the Documentation tab for server configuration examples.
GPU detection works best in Chromium browsers with Client Hints. Safari and Firefox have limited support. Also, some browsers may restrict this information for privacy reasons.
Check browser console for errors, ensure you're using a supported browser version, and verify that your server is sending proper Client Hints headers (see the Documentation tab for Server Configuration).
Accept-CH: Sec-CH-UA, Sec-CH-UA-Mobile, Sec-CH-UA-Platform, Sec-CH-UA-Platform-Version, Sec-CH-UA-Arch, Sec-CH-UA-Bitness
Loading...
Name, version, rendering engine
Windows, macOS, Linux, iOS, Android
CPU cores, RAM, GPU, Apple Silicon
Public IP, ISP, country (cached)
Resolution, pixel ratio, orientation
Charging state, level percentage
npm install aki-info-detect
# or
yarn add aki-info-detect
# or
pnpm add aki-info-detect
<script type="module">
import akiInfoDetect from 'https://unpkg.com/aki-info-detect/dist/aki-info-detect.js';
const info = await akiInfoDetect();
console.log(info);
</script>
<script src="https://unpkg.com/aki-info-detect/dist/aki-info-detect.umd.cjs"></script>
<script>
akiInfoDetect().then(info => console.log(info));
</script>
import akiInfoDetect from 'aki-info-detect';
// Get all info
const info = await akiInfoDetect();
console.log(info.browser); // "Chrome 120.0"
console.log(info.os.name); // "macOS"
console.log(info.CPU); // "Apple M3 Pro"
// Tree-shakeable imports
import { detectBrowser, detectOS } from 'aki-info-detect';
const browser = detectBrowser();
const os = detectOS();
For deep hardware detection, configure your server to send Client Hints headers:
app.use((req, res, next) => {
res.setHeader('Accept-CH',
'Sec-CH-UA, Sec-CH-UA-Mobile, Sec-CH-UA-Platform, ' +
'Sec-CH-UA-Platform-Version, Sec-CH-UA-Arch, Sec-CH-UA-Bitness'
);
next();
});
add_header Accept-CH "Sec-CH-UA, Sec-CH-UA-Mobile, Sec-CH-UA-Platform, Sec-CH-UA-Platform-Version, Sec-CH-UA-Arch, Sec-CH-UA-Bitness";
// vite.config.js
export default {
server: {
headers: {
'Accept-CH': 'Sec-CH-UA, Sec-CH-UA-Mobile, Sec-CH-UA-Platform, ...'
}
}
};
All modern browsers with ES2020+ support:
akiInfoDetect()Returns a Promise that resolves to an object containing all detected information.
const info = await akiInfoDetect();
{
// Browser info
browser: string, // "Chrome 120.0"
product: string, // "Gecko"
manufacturer: string, // "Google Inc."
isMobile: boolean, // true/false
language: string, // "en-US"
// OS info
os: {
name: string, // "macOS"
version: string, // "14.1.2"
string: string // "macOS 14.1.2"
},
// Hardware
CPU: string, // "Apple M3 Pro"
CPUCore: number, // 12
arch: string, // "arm64"
RAM: number, // 16 (GB)
GPU: string, // "Apple M3 Pro"
// Battery
battery: {
isCharging: boolean, // true/false
level: number // 0-100
},
// Methods
getScreen: () => Object,
getConnection: () => Object,
getIP: () => Promise<string>,
getISP: () => Promise<string>,
getCountry: () => Promise<string>,
getLocation: () => Promise<Object>
}
detectBrowser()Returns browser name and version.
import { detectBrowser } from 'aki-info-detect';
const browser = detectBrowser(); // "Chrome 120.0"
detectOS()Returns OS information.
import { detectOS } from 'aki-info-detect';
const os = detectOS();
// { name: "macOS", version: "14.1.2", string: "macOS 14.1.2" }
getHardwareInfo()Returns CPU, GPU, RAM information (async).
import { getHardwareInfo } from 'aki-info-detect';
const hw = await getHardwareInfo();
// { CPU: "...", cores: 12, arch: "...", RAM: 16, GPU: "..." }
getNetworkInfo()Returns network information with caching (async).
import { getNetworkInfo } from 'aki-info-detect';
const net = await getNetworkInfo();
// { ip: "...", isp: "...", country: "..." }
getScreen()Returns screen dimensions and properties.
import { getScreen } from 'aki-info-detect';
const screen = getScreen();
// { width: 1920, height: 1080, pixelRatio: 2, ... }
getBattery()Returns battery status (async).
import { getBattery } from 'aki-info-detect';
const battery = await getBattery();
// { isCharging: true, level: 85 }
Network requests (IP, ISP, Country) are cached for 1 hour to reduce API calls.
// First call: fetches from API
const ip1 = await info.getIP();
// Within 1 hour: returns cached value
const ip2 = await info.getIP();
try {
const info = await akiInfoDetect();
console.log(info.browser);
} catch (error) {
console.error('Detection failed:', error);
}
Full TypeScript declarations included.
import akiInfoDetect, { type DetectionResult } from 'aki-info-detect';
const info: DetectionResult = await akiInfoDetect();