Lightweight browser, device & network detection library
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();