Skip to main content

setScreenAwakeMode

Prevents the screen from automatically dimming and locking. Use this for features where the user needs the screen on without touching it — navigation maps, workout tracking, recipe reading.

Signature

import { setScreenAwakeMode } from '@apps-in-toss/web-framework';

declare function setScreenAwakeMode(options: {
enabled: boolean;
}): Promise<{ enabled: boolean }>;

Parameters

NameTypeRequiredDescription
options.enabledbooleantrue to prevent the screen from dimming; false to restore normal behavior.

Returns

  • Promise<{ enabled: boolean }> — resolves with the current enabled state after the setting is applied.
Always release the lock

Screen-awake mode drains the battery quickly. Call setScreenAwakeMode({ enabled: false }) when the feature is done or the component unmounts. A useEffect cleanup is the right place.

Permission

No permission required.

Examples

Minimal

import { setScreenAwakeMode } from '@apps-in-toss/web-framework';

await setScreenAwakeMode({ enabled: true });

Realistic — navigation map screen

import { setScreenAwakeMode } from '@apps-in-toss/web-framework';
import { useEffect } from 'react';

export function NavigationMap() {
useEffect(() => {
// Keep the screen on while navigating.
setScreenAwakeMode({ enabled: true });

return () => {
// Release when leaving.
setScreenAwakeMode({ enabled: false });
};
}, []);

return <div>{/* Map component */}</div>;
}

Try it live

Open the Navigation page in sdk-example and run the setScreenAwakeMode card.

Open in sdk-example

External references