Amazon Developer

as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
Ring
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support
Skip to main content
Use the Vega WebView components to integrate, optimize, and deliver standard web apps on Vega OS. This guide covers the essential workflows for bridging web content with native Fire TV features, ensuring high-performance media playback, and adapting your web app for a 10-foot television experience.

Set the initial focus to WebView

To set the focus to WebView, do the following. In the src/App.tsx file, set the initial focus by adding the hasTVPreferredFocus={true} prop to the WebView component.

Send and receive messages from WebView pages

You can send and receive messages with WebView for Vega. To send and receive messages, use the following options:
  • React Native for Vega -> Web: The injectJavaScript method.
  • Web -> React Native for Vega: The onMessage prop.

Implement Vega device Fire TV features from a web page

The window.ReactNativeWebView.postMessage method runs the onMessage prop in React Native for Vega, which you can use to trigger Vega device Fire TV features. window.ReactNativeWebView.postMessage only accepts one argument, which must be a string.

Checking HDR format and codec support in WebView for Vega

WebView currently supports HEVC Main10 (HLG, HDR10, HDR10+) and VP9 Profile2 (HLG, HDR10) on the current Fire TV device. Current Fire TV devices don’t yet support AV1 HDR. Don’t use H264 and VP8 codecs for HDR. Check for HDR availability by using canPlayType() or isTypeSupported().

Enable back-button remote key events in web JavaScript

The allowSystemKeyEvents property controls whether the web app actively listens for specific system key events, such as the back button (identified by keyCode: 27). To enable back-button remote key events, do the following.
  • In the src/App.tsx file, set the allowSystemKeyEvents property to true.

Enable and use DevTools for debugging

Chrome DevTools is enabled by default when you build the app with the debug version (process.env.NODE_ENV = 'development'). To build the DevTools debug app, do the following.
  • At the command prompt, run the following command.
Complete the following steps to use the DevTools effectively. To use the DevTools for debugging, do the following.
  1. Install and launch the debug app, which opens a WebView.
  2. Perform port forwarding at the command prompt by running the following command.
  3. Open Google Chrome, and then navigate to chrome://inspect/#devices.
  4. Find DevTools in the Remote Target section, in the list of connected devices.
  5. Open DevTools, by selecting inspect, and inspect the WebView.
For more information, see Debugging Web Apps with Vega Studio.

Supported remote key events

The following table shows the supported remote key events and their associated key codes.

Example checking for HDR using canPlayType()

Example checking for HDR using isTypeSupported()

Don’t use MediaCapabilities.decodingInfo() because there are known issues. It reports VP9 Profile 2 support as false.

Example using HEVC

How to override default media control handlers

Some apps require granular control over media playback beyond what the default WebView media controls offer. Here are some examples.
  • Disabling seek operation during advertisements.
  • Disabling all media control during live playback.
To achieve this level of granular control, developers have two options:
  • Web-based implementation using navigator.mediaSession. For this implementation, enable allowsDefaultMediaControl for these reasons.
    • It enables transport control for play, pause, skip forward, and skip backward.
    • It works directly in the web page without app code changes.
  • Direct integration with the VegaMediaControl interface in your app code. For this integration, disable allowsDefaultMediaControl for these reasons.
    • It provides full access to the device’s media control capabilities.
    • It’s recommended for apps requiring deep system integration.

Web-based implementation using navigator.mediaSession

The navigator.mediaSession property is a web standard that provides a powerful interface between webpage media content and the device media control system. It enables web apps to register action handlers for media controls for the currently playing media, and customize how media controls behave across different content. When allowsDefaultMediaControl is set to true in WebView, system-level controls like Alexa voice commands pass to registered custom handlers if available. Without registered handlers, WebView reverts to its default implementation. Custom handler use can then be based on playback context such as during advertisements or live streams. For example, when users say, “Alexa, fast forward” with allowsDefaultMediaControl set to true, WebView passes the command to the web page’s seekforward handler if it’s registered. If the developer doesn’t register a handler, WebView falls back to its default seek implementation. This feature lets the web page control seeking behavior based on the content playing, such as blocking seeks during advertisements.

Example using navigator.mediaSession

Integration with VegaMediaControl interface in app

VegaMediaControl provides an interface for managing media playback in Vega apps. This direct integration enables granular control over media features such as playback controls, and seeking operations. To integrate your Vega Web App with VegaMediaControl, follow these key steps:
  1. Configure the WebView Prop.
    • The default media control in WebView is disabled by default. To keep the controls disabled, either leave the prop unset or explicitly set allowsDefaultMediaControl to false. To use the VegaMediaControl integration, keep the default media control disabled.
  2. Implement the VegaMediaControl Interface.
    • Add VegaMediaControl integration to your app
  3. JavaScript Bridge Communication
    • Use injectJavaScript to control the web player according to VegaMediaControl handlers.

Example integrating VegaMediaControl in your app code

The following is a detailed example demonstrating how to handle pause, play, seek forward, and seek backward commands. All of these commands use VegaMediaControl in your Vega Web App.
  1. Add support for VegaMediaControl in manifest.toml. Update the manifest for KMC, along with other entries.
  2. Add the following dependencies to package.json.
  3. The following app code example creates the KMC server and the associated handler. Those handlers can inject JavaScript into the webpage with custom behavior.

Load a local file URL stored on the device into a WebView

By default, WebView loads apps from the /pkg/assets directory. However, you must set a property to true if you want to load an app file from a different directory. To load a local app file URL stored on the device, do the following.
  • In the src/App.tsx, set the allowFileAccess property to true.
Setting the property to true enables WebView access and the ability to display the app file from the chosen directory. Failure to set allowFileAccess to true when you try to load an app file from a different directory causes an “Access Denied” error. The file app functions within a sandboxed environment, limiting its access to the device’s file system. See the directories that the file app can access in the following table.

Example: Use WebView to load an HTML file from the assets directory

Example: Use WebView to load an HTML file from the app data directory

D-Pad navigation in WebView

WebView has spatial navigation enabled by default to provide basic D-Pad navigation.

Prevent spatial navigation in WebView

For apps that implement custom focus management rather than the default spatial navigation focus, apps can use Event::preventDefault when catching the keydown event. Using Event::preventDefault prevents conflicts between the custom focus logic and built-in WebView spatial navigation. To manage serialized cookies or to clear cookies for your app, see Vega Web App Cookie Manager. To view other WebView APIs, see Vega Web App Component Reference.

How to prevent a flashing white screen before the page loads

Before loading a webpage, the view uses the component’s background color. If you don’t set the background color, then WebView chooses a white background. To change the background color, update the backgroundColor style of the WebView component.
Modify the background color of the WebView style according to your needs.

How to remove the remote playback icon at the top of the video playback screen

If WebView displays an icon at the top of the screen, the disableRemotePlayback property may have caused it. Remove the icon by setting the property to true. A true property means it’s disabled, while false means it remains enabled. Here’s an example:

How to selectively allow or block HTTP

Starting with WebView version 4.0.2 (RN 0.83), WebView prevents apps from loading plain-text (HTTP) URLs due to security concerns. However, there are some use-cases where app developers may need to load plain-text URLs. Apps can be configured to allow or block domains in their app manifest file.

How it works

If no network-traffic-policy.cleartext section is present in the manifest, all HTTP requests are blocked. Only HTTPS URLs load. This change applies beginning with WebView 4.0.2 (RN 0.83). Apps on WebView 3.5.11 (RN 0.72) or lower versions aren’t affected. When both allowed-domains and blocked-domains are specified, blocked-domains take priority.

Common use cases

  • Allow all HTTP except a few domains (blocklist). Example: Allow cleartext for the whole application except sensitive domains.
  • Block all HTTP except specific domains (allowlist). Example: Don’t enable cleartext for the whole application but trust specific domains.
  • Block all HTTP (no exceptions). Example: Don’t allow cleartext at all.
  • Allow all HTTP (no restrictions). Example: Allow cleartext for all domains. Perhaps for a captive portal app, or network diagnostics.

Last modified on July 28, 2026