Skip to main content

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.

Open in sdk-example

External references