Skip to main content

Documentation Index

Fetch the complete documentation index at: https://setup.despia.com/llms.txt

Use this file to discover all available pages before exploring further.

When a keyboard appears, iOS and Android both attempt to resize or reposition the WebView automatically. If your web app is already full-height and manages keyboard avoidance in JavaScript, this native adjustment creates a white gap below the keyboard and disrupts your layout. The preventdefault://autoscroll scheme disables that native behavior and lets you opt back in at any time.

Installation

npm install despia-native
import despia from 'despia-native';

How it works

Call preventdefault://autoscroll with enabled=false to stop the native layer from moving the WebView when the keyboard opens. Call with enabled=true to restore the default behavior.
const isDespia = navigator.userAgent.toLowerCase().includes('despia')

if (isDespia) {
    // Disable native keyboard resize - your JS handles layout instead
    despia('preventdefault://autoscroll?enabled=false')
}
To restore native behavior later:
if (isDespia) {
    despia('preventdefault://autoscroll?enabled=true')
}

Disable on app load

The most common pattern is to disable native keyboard resizing once on startup, before any input is focused. This ensures the WebView never shifts position during the session.
const isDespia = navigator.userAgent.toLowerCase().includes('despia')

document.addEventListener('DOMContentLoaded', () => {
    if (isDespia) {
        despia('preventdefault://autoscroll?enabled=false')
    }
})

Selectively re-enable for specific inputs

If one part of your app relies on native scroll behavior - such as a form that does not manage its own keyboard avoidance - you can toggle the mode per interaction.
const isDespia = navigator.userAgent.toLowerCase().includes('despia')

function onNativeFormFocus() {
    if (isDespia) despia('preventdefault://autoscroll?enabled=true')
}

function onNativeFormBlur() {
    if (isDespia) despia('preventdefault://autoscroll?enabled=false')
}

Platform behavior

The scheme maps to different native APIs on each platform but produces the same result - the WebView holds its position when the keyboard appears.
ParameteriOSAndroid
?enabled=falsecontentInsetAdjustmentBehavior = .never - WebView stays putSOFT_INPUT_ADJUST_NOTHING - window does not resize
?enabled=truecontentInsetAdjustmentBehavior = .automatic - native behavior restoredSOFT_INPUT_ADJUST_RESIZE - native behavior restored

Resources

NPM Package

despia-native