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
React Native for Vega provides native implementations of Uint8Array static and instance methods as listed in MDN web docs to support efficient binary data encoding and decoding. Working with binary data is a common requirement in many applications. React Native for Vega provides optimized methods for converting between binary data (Uint8Array) and string representations (base64 and hexadecimal). These methods are added to the global Uint8Array object and are available throughout your application without requiring any imports.

Key features

  • Efficient binary-to-string conversions: Convert binary data to and from base64 and hexadecimal strings
  • Native implementation: Methods are optimized for performance using native code
  • Standard compatibility: Fully compatible with the standard JavaScript Uint8Array API

Common use cases

Static methods


Uint8Array.fromBase64(string)
Creates a new Uint8Array from a base64-encoded string.
Parameters:
  • base64String: A string containing base64-encoded data
Returns: A new Uint8Array containing the decoded data Example:

Uint8Array.fromHex(string)
Creates a new Uint8Array from a hexadecimal string.
Parameters:
  • hexString: A string containing hexadecimal data (must have an even length and contain only valid hex characters)
Returns: A new Uint8Array containing the decoded data Example:

Instance methods


Uint8Array.prototype.toBase64()
Converts the Uint8Array to a base64-encoded string.
Returns: A base64-encoded string representing the binary data Example:

Uint8Array.prototype.toHex()
Converts the Uint8Array to a hexadecimal string.
Returns: A hexadecimal string representing the binary data Example:

Uint8Array.prototype.setFromBase64(string)
Populates the Uint8Array with data from a base64-encoded string.
Parameters:
  • base64String: A string containing base64-encoded data
Returns: An object with:
  • read: Number of characters read from the input string
  • written: Number of bytes written to the Uint8Array
Example:

Uint8Array.prototype.setFromHex(string)
Populates the Uint8Array with data from a hexadecimal string.
Parameters:
  • hexString: A string containing hexadecimal data (must have an even length and contain only valid hex characters)
Returns: An object with:
  • read: Number of characters read from the input string
  • written: Number of bytes written to the Uint8Array
Example:

Troubleshooting

  • Only the standard base64 alphabet is supported (no base64url variant).
  • Hexadecimal strings must have an even length and contain only valid hex characters (0-9, A-F, a-f).

Additional resources

MDN Web Docs
Last modified on December 10, 2025