getDeviceId
Synchronously returns the unique identifier for the current device. Useful for per-device settings storage, log analytics, and distinguishing multiple devices belonging to the same user.
Signature
import { getDeviceId } from '@apps-in-toss/web-framework';
declare function getDeviceId(): string;
Parameters
None.
Returns
string— the device's unique identifier. Format may differ between iOS and Android.
Device ID can change
The device ID can change after a factory reset, OS upgrade, or app reinstall. For persistent user identification, combine with a server-side user ID.
Permission
No permission required — getDeviceId is not bound to a PermissionName. For the typical permission flow used by other namespaces, see Guides — Permissions pattern.
Examples
Minimal
import { getDeviceId } from '@apps-in-toss/web-framework';
const deviceId = getDeviceId();
console.log('Device ID:', deviceId);
Realistic — render device info on screen
import { getDeviceId } from '@apps-in-toss/web-framework';
import { useState, useEffect } from 'react';
function DeviceSettingsPage() {
const [deviceId, setDeviceId] = useState('');
useEffect(() => {
const id = getDeviceId();
setDeviceId(id);
}, []);
return (
<div>
<h2>Device Info</h2>
<p>Device ID: <code>{deviceId || 'Loading...'}</code></p>
</div>
);
}
Try it live
Open the Environment page in sdk-example and run the getDeviceId card to inspect the result.
Related APIs
getPlatformOS— returns the device's platform OS (ios/android).getTossAppVersion— returns the Toss app version.getGroupId— returns the group ID assigned by Apps in Toss.
Related guides
- Guides — Permissions pattern — permission flow used by other namespaces (reference only;
getDeviceIddoesn't require a permission). - Recipes — Device-ID-based log tracing
External references
@apps-in-toss/web-framework— SDK package. The actual exports are re-exported from@apps-in-toss/web-bridge.- Web standard counterpart: none — the standard Web API does not expose a device-unique identifier.
navigator.userAgentconveys device information but does not guarantee uniqueness per device.