Skip to content
0.2.0 문서입니다. 설치한 버전의 API와 변경 사항을 확인하세요.

Props ​

NitroWebView는 React Native 뷰의 레이아웃 prop과 아래 WebView prop을 받습니다. 모든 이벤트·hybrid ref 콜백을 callback()으로 감싸세요.

콘텐츠와 설정 ​

PropType동작
sourceWebViewSourceURI 또는 HTML. 필수.
defaultHeadersRecord<string, string>Source 로드의 기본 헤더. Source 헤더가 대소문자 구분 없이 우선.
userAgentstring모든 WebView 요청의 UA 변경. 빈 문자열은 기본값 복원.
javaScriptEnabledboolean기본 true. Android 변경 가능, iOS 초기 설정.
domStorageEnabledboolean기본 true. Android만 적용. iOS는 DOM storage 항상 활성화.
cacheEnabledbooleanAndroid 캐시 모드. iOS는 다음 source 로드의 요청 정책.
incognitoboolean기본 false. iOS 별도 비영구 store. Android는 true 거부.
sharedCookiesEnabledboolean기본 false. iOS 첫 로드 전 앱 쿠키를 한 번 가져옴.
thirdPartyCookiesEnabledbooleanAndroid 뷰별 third-party cookie 정책. iOS 무시.
scrollEnabledboolean기본 true. iOS만 적용. Android no-op.
bouncesboolean기본 true. iOS만 적용. Android no-op.
scalesPageToFitboolean기본 false. Android overview·wide viewport. iOS no-op.
allowsBackForwardNavigationGesturesboolean기본 false. iOS 히스토리 swipe. Android no-op.
mediaPlaybackRequiresUserActionboolean기본 true. iOS 초기 설정. Android 변경 가능.
allowsInlineMediaPlaybackbooleaniOS 기본 false. HTML playsinline 필요. Android는 기본 inline.
injectedJavaScriptstring페이지 로드의 document-end 주입.
injectedJavaScriptBeforeContentLoadedstringMain frame의 시작 주입. 이전 Android WebView는 대체 시점 사용.
allowedMessageOriginsstring[]정확한 HTTP(S) origin. 생략 시 모두 허용, []는 모두 차단.
mediaCapturePermissionOriginsstring[]Android 카메라·마이크 origin. 기본 모두 차단.
geolocationPermissionOriginsstring[]Android 위치 origin. 기본 모두 차단.
interceptSubframeNavigationboolean기본 false. Android iframe 가로채기 활성화. iOS 무시.

콜백과 ref ​

hybridRef는 NitroWebViewType을 받는 콜백입니다. 일반 React ref는 host ref입니다. 메서드는 hybrid ref로 호출합니다.

Callback인자동작
onLoadStartWebViewLoadEventMain document 로드 시작.
onLoadWebViewLoadEvent성공한 로드에만 발생. onLoadEnd보다 먼저 발생.
onLoadProgressWebViewLoadProgressEventnativeEvent.progress의 0~1 추정 진행률.
onLoadEndWebViewLoadEvent실패를 포함한 로드 종료 이벤트.
onNavigationStateChangeWebViewNavigationStatenativeEvent wrapper 없는 직접 상태. SPA 히스토리 포함.
onMessageWebViewMessageEvent페이지 문자열과 제공 가능한 네이티브 발신 정보.
onErrorNitroWebViewErrorEvent전송·설정·source·blob 오류 등. Domain 확인.
onHttpErrorNitroWebViewHttpErrorEventMain frame HTTP 4xx/5xx. 하위 리소스 제외.
onFileDownloadFileDownloadEventHTTP 메타데이터 또는 플랫폼별 blob 참조.
onOpenWindowOpenWindowEvent새 창 목적지 알림. 현재 뷰에서 여는 기본 동작 생략.
onRenderProcessGoneNitroWebViewRenderProcessGoneEventAndroid API 26+는 뷰 파괴. iOS는 reload로 복구.
onScrollNitroWebViewScrollEventThrottling 없는 scroll 이벤트. Geometry는 플랫폼별로 다름.
onShouldStartLoadWithRequestShouldStartLoadRequestboolean 또는 Promise<boolean> 반환. 플랫폼별 대기·적용 범위 확인.

초기 설정 ​

iOS의 incognito, sharedCookiesEnabled, javaScriptEnabled, mediaPlaybackRequiresUserAction, allowsInlineMediaPlayback은 첫 로드 전에 적용합니다. 변경하려면 React key를 바꿔 다시 마운트하세요.

탐색 · 메시지 · 플랫폼별 차이에서 제한을 확인하세요.

MIT licensed · Built with Nitro Modules