<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bartłomiej Bukowski on Medium]]></title>
        <description><![CDATA[Stories by Bartłomiej Bukowski on Medium]]></description>
        <link>https://medium.com/@bbarthec?source=rss-78e73e572503------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*KMWVwdbEW088hLWnJHlZVA.jpeg</url>
            <title>Stories by Bartłomiej Bukowski on Medium</title>
            <link>https://medium.com/@bbarthec?source=rss-78e73e572503------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 13:58:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bbarthec/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[React Native for Vega: Recreating Apple & Google Photos in RN — Part 3]]></title>
            <link>https://medium.com/swmansion/react-native-for-vega-recreating-apple-google-photos-in-rn-part-3-f015e9272aed?source=rss-78e73e572503------2</link>
            <guid isPermaLink="false">https://medium.com/p/f015e9272aed</guid>
            <category><![CDATA[vega-os]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[amazon-developer]]></category>
            <dc:creator><![CDATA[Bartłomiej Bukowski]]></dc:creator>
            <pubDate>Tue, 04 Nov 2025 16:25:56 GMT</pubDate>
            <atom:updated>2025-11-05T09:10:03.140Z</atom:updated>
            <content:encoded><![CDATA[<h3>React Native for Vega: Recreating Apple &amp; Google Photos in RN — Part 3</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I-isbPEYTZwNZ1BrQViYjg.png" /></figure><p>Welcome to the third part of our Apple Photos series, where we’ll take a closer look at building a multiplatform photo gallery. Previously, we showed you <a href="https://blog.swmansion.com/react-native-multiplatform-recreating-apple-google-photos-in-react-native-part-2-832398eb0d4c">how to create a gallery app that runs smoothly across mobile, TV, and web using React Native</a>.</p><p><strong>This time, we’re pushing the challenge further by developing for Amazon’s next-generation devices with the Vega platform.</strong></p><h3>About Vega</h3><p><strong>React Native for Vega is a just-released React Native platform designed specifically to support app development on Amazon’s Vega OS.</strong> It’s currently based on React Native 0.72 and supports the New Architecture, including Fabric and TurboModules. The main idea behind the platform is to integrate React Native <strong>at the operating system level</strong> instead of packing it with the app itself. This makes it possible to reduce the app size, thus improving startup time.</p><p>Using the Vega platform opens the door to creating apps for Amazon’s next-generation devices, including:</p><ul><li>Echo Show series</li><li>Echo Hub series</li><li>Echo Spot series</li><li>Next-gen Fire TV</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6M6tpS6aHZqaunRCQrXqSA.jpeg" /><figcaption>Amazon Echo devices</figcaption></figure><p>Developing for the Vega platform is definitely made easier with the Vega developer tools. It’s a suite of development and testing tools aiming to simplify workflows and accelerate the build process. The table below covers the most important tools of the Vega developer tools:</p><ul><li><strong>Vega Libraries</strong> — a set of third-party library implementations compatible with Vega,</li><li><strong>Vega Studio</strong> — a VS Code extension that automates building &amp; running Vega apps,</li><li><strong>Vega CLI</strong> — a command tool to build an app &amp; work with device / simulator,</li><li><strong>VDA</strong> — a command line utility for handling Vega app’s binaries,</li><li><strong>Vega Virtual Device</strong> — a simulator that lets you test Vega apps without a physical device.</li></ul><p>You can find more information in the official <a href="https://developer.amazon.com/docs/vega/0.21/vega-overview.html">Amazon’s documentation</a>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FtB-XfLBYTxQ%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DtB-XfLBYTxQ&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FtB-XfLBYTxQ%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e622957ba91a37f5816f97a2c0e0025f/href">https://medium.com/media/e622957ba91a37f5816f97a2c0e0025f/href</a></iframe><h3>Building a Vega app</h3><p>Before diving into adding Vega support to our multiplatform Photos gallery app, let’s quickly go over what’s required to build and run an app on Vega.</p><h4>Project template</h4><p>The easiest way to start a Vega project is by using the Vega CLI to generate a project template. Each template includes essential configuration files that you can customize to suit your app’s specific needs.</p><pre>kepler project list-templates # Lists available templates<br><br>kepler project generate \<br>  --template `&lt;TEMPLATE&gt;` \<br>  --name `&lt;APPNAME&gt;` \<br>  --outputDir `&lt;OUTPUTDIR&gt;`</pre><h4>Workflow</h4><p>Vega apps need to be built using React Native’s bare workflow. This workflow gives developers full control over the app’s configuration and build process, exposing the native project structure, but it also requires manual setup. Unlike managed workflows like Expo, the bare workflow doesn’t abstract platform-specific settings; something essential when integrating with system-level components, as in the case of Vega apps.</p><p>To handle bundling and code transformation in the bare workflow, we use <strong>Metro </strong>and <strong>Babel</strong>. If you’re building exclusively for Vega, the minimal configuration generated from the template is usually sufficient, relying on the default setup from @react-native/metro-config. However, if you want to build an app with support for other platforms, additional steps are necessary — more on that later.</p><h4>Configuration</h4><p>To begin with, Vega and developer tools require a manifest.toml file to recognize and properly install the application. This file contains app’s metadata, as well as requested system capabilities. When building a Vega app, the manifest file is organized into sections, with the most important being:</p><ul><li>schema-version<strong>: </strong>required, schema version used in the manifest file,</li><li>[package]: required, metadata of the package (app) — including <strong>id, title</strong> and <strong>icon,</strong></li><li>[components]: required, declares the components bundled into the package. Components can be either <strong>interactive</strong>,<strong> service </strong>or<strong> task</strong>. Each app which isn’t a library-only package and/or displays graphical content, should declare an interactive component,</li><li>[needs]<strong> / </strong>[wants]: optional, specifies the system capabilities the app requires or can use optionally to function properly on a Vega device.</li></ul><p>The code below shows an example manifest file from our Photos gallery app:</p><pre># manifest.toml<br>schema-version = 1<br><br>[package]<br>title = &quot;SWM Photos Gallery app for Vega&quot;<br>version = &quot;1.0.0&quot;<br>id = &quot;com.swmansion.photos&quot;<br>icon = &quot;@image/vega-icon.png&quot;<br><br>[components]<br>[[components.interactive]]<br>id = &quot;com.swmansion.photos.main&quot;<br>runtime-module = &quot;/com.amazon.kepler.keplerscript.runtime.loader_2@IKeplerScript_2_0&quot;<br>launch-type = &quot;singleton&quot;<br>categories = [&quot;com.amazon.category.main&quot;]</pre><p>For a full description of the manifest file configuration, please visit the <a href="https://developer.amazon.com/docs/vega/0.21/app-manifest.html">official documentation</a>.</p><p>In addition to that, you should also configure your package.json file by providing essential build intrinsics, as well as used libraries. Vega comes with its own, native implementations of the most popular React Native, Expo and community libraries, which should be used to ensure compatibility with the platform. Each of the Vega-specific implementations is preceded with @amzn scope prefix. You can explore all available libraries and packages <a href="https://developer.amazon.com/docs/kepler-tv/supported-libraries.html">here</a>.</p><p>The code below shows a minimal configuration of Vega build properties and libraries in package.json. You can find the full configuration in <a href="https://github.com/software-mansion-labs/swm-react-native-labs-swm-photos/blob/episode-3/kepler/package.json">our repository</a>.</p><pre># package.json<br>{<br>  &quot;dependencies&quot;: {<br>    &quot;@amzn/react-native-kepler&quot;: &quot;~2.0.0&quot;,<br>    &quot;@amzn/react-native-reanimated&quot;: &quot;~2.0.0&quot;,<br>    &quot;react&quot;: &quot;18.2.0&quot;,<br>    &quot;react-native&quot;: &quot;0.72.0&quot;,<br>  },<br>  &quot;kepler&quot;: {<br>    &quot;projectType&quot;: &quot;application&quot;,<br>    &quot;appName&quot;: &quot;SWMPhotos&quot;,<br>    &quot;targets&quot;: [&quot;tv&quot;],<br>  }<br>}</pre><h4>Development</h4><p>Development in Vega is fairly straightforward. Since it’s based on React Native 0.72, creating an app mostly follows the usual React Native workflow.</p><p>Vega, however, differs from standard React Native in its approach to focus management, offering support for both remote controllers and voice navigation features. It:</p><ul><li>Adopts focus management techniques known from react-native-tvos fork, such as such as the nextFocusUp, nextFocusDown, nextFocusLeft, and nextFocusRight props to enhance directional control,</li><li>Introduces specialized FocusManager turbo module featuring an imperative API for focus management, with methods such as setNextFocus() or clearNextFocus(),</li><li>Integrates ARIA<strong> </strong>(Accessible Rich Internet Applications) features with Alexa<strong> </strong>voice control to allow voice-guided on-screen navigation through props such as aria-label and alexaEntityType.</li></ul><p>For more details on Vega navigation, see the <a href="https://developer.amazon.com/docs/vega/0.21/dev-guides-overview.html">Vega developer guides</a> in the official Amazon documentation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K6ASjTnns5ufFsewrcvzJQ.jpeg" /><figcaption>Vega focus navigation taxonomy</figcaption></figure><p>Another key difference in Vega is its file system model: apps run in a sandboxed environment with /pkg as the root and limited access beyond it. You can learn more about the Vega file system in the <a href="https://developer.amazon.com/docs/vega-api/0.21/README.amazon_devices_kepler-file-system.html">API documentation</a>.</p><h4>Build and run</h4><p>Unlike standard React Native, a Vega app must first be built and packaged into a .vpkg binary archive. This can be done using the build-kepler command:</p><pre># Get available build targets<br>kepler build help<br><br># Build the app for given target<br>npx react-native build-kepler \<br>  --build-type `&lt;Debug/Release&gt;` \<br>  --target `&lt;BUILD_TARGET&gt;`</pre><p>This produces a .vpkg binary in the local build directory, with a relative path depending on a given build type and target (typically ./build/&lt;TARGET&gt;-&lt;BUILD_TYPE&gt;/&lt;PACKAGE_NAME&gt;_&lt;TARGET&gt;.vpkg).</p><p>Next step is to install the package on the Vega device or simulator, which can be done using Vega CLI:</p><pre># List all connected Vega devices and simulators<br>kepler device list<br><br># Install the package on selected device<br>kepler device install-app \<br>  -p `&lt;PATH_TO_VPKG&gt;`<br>  --device `&lt;DEVICE_NAME&gt;`</pre><p>To launch the app on the selected device, you can use the launch-app command and specify the interactive component ID (the one from manifest.toml file):</p><pre>kepler device launch-app \<br>  --device &lt;DEVICE_NAME&gt; \<br>  --appName `&lt;INTERACTIVE_ID&gt;`</pre><p>For the Photos Gallery app, we created a Bun script that automates the entire process, letting us build and run the app with a single command. You can check the implementation <a href="https://github.com/software-mansion-labs/swm-react-native-labs-swm-photos/blob/episode-3/kepler/kepler-install.ts">here</a>.</p><h4>Cross-platform integration</h4><p>Since Vega comes with its unique environment and build process, integrating it with an existing app designed to support other platforms raises additional challenges, from configuration to design aspects. <strong>In the following sections, we’ll walk through adding Vega support to an existing multiplatform React Native app, using our Photos Gallery app (which already supports Android, iOS, TVs, and the web) as an example.</strong></p><h4>Project structure</h4><p>In our project, we use a monorepo setup — a single repository for all code and assets across builds. To manage the workflow and configuration differences for Vega, we recommend creating a separate subdirectory for the Vega build. This directory should contain the configuration files mentioned in the <a href="https://medium.com/swmansion/react-native-multiplatform-recreating-apple-google-photos-in-react-native-part-2-832398eb0d4c">previous chapter</a> of the article, either created manually or generated from existing project templates. Below is a simplified project structure from our repository:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l37u5rADDzYwY1RPFebKnw.jpeg" /><figcaption>Vega project directories structure</figcaption></figure><p>As you can see, there is only one global source code directory, outside the ./vega location. This means that each source file must be resolved from the external directory to ensure a proper build process.</p><h4>Resolving external source files</h4><p>To address the issue mentioned earlier, it’s essential to properly configure the Metro resolver, including:</p><ol><li>Adding the source (and assets) directory to Metro’s watchFolders to specify where it should look for additional files to resolve,</li><li><em>(Optional)</em> Adding local node modules to Metro’s resolver to explicitly tell Metro where to search for libraries and packages,</li><li>Disabling hierarchical lookup to prevent Metro from resolving unnecessary configuration files or node modules from the parent Expo workflow directory.</li></ol><p>Here’s an example Metro configuration that covers all the steps we’ve discussed:</p><pre>// vega/metro.config.js<br>const path = require(&quot;path&quot;);<br><br>const config = {<br>  watchFolders: [<br>    path.resolve(__dirname, &quot;../src&quot;),<br>    path.resolve(__dirname, &quot;../assets&quot;)<br>  ],<br>  resolver: {<br>    nodeModulesPaths: [path.resolve(__dirname, &quot;node_modules&quot;)],<br>    disableHierarchicalLookup: true<br>  }<br>};<br><br>module.exports = mergeConfig(getDefaultConfig(__dirname), config);</pre><h4>Managing package variants</h4><p>As mentioned in the configuration part, Vega comes with its own implementation of popular React Native &amp; Expo libraries, all preceded with @amzn prefix. To handle imports cleanly without modifying the source code, we use Babel aliases in the Vega build, as shown in the example below:</p><pre>// vega/babel.config.js<br>const path = require(&quot;path&quot;);<br><br>module.exports = {<br>  presets: [&quot;module:metro-react-native-babel-preset&quot;],<br>  plugins: [<br>    [&quot;module-resolver&quot;, {<br>      root: [&quot;../src&quot;],<br>      alias: {<br>        &quot;@&quot;: &quot;../src&quot;,<br>        &quot;expo-image&quot;: path.resolve(__dirname, &quot;node_modules&quot;,<br>                                   &quot;@amzn/expo-image&quot;),<br>        &quot;react-native-mmkv&quot;: path.resolve(__dirname, &quot;node_modules&quot;,<br>                                          &quot;@amzn/react-native-mmkv&quot;),<br>      },<br>    }],<br>  ],<br>};</pre><p>Note that we also configure the @ symbol to resolve to the source code root.</p><p>The full Babel configuration is available in <a href="https://github.com/software-mansion-labs/swm-react-native-labs-swm-photos/blob/episode-3/kepler/babel.config.js">our repository</a>.</p><h4>Library compatibility</h4><p>While Vega supports most commonly used libraries, a few are either unsupported or only partially supported. In our project, we found four packages that needed modifications or complete replacements due to incompatibility with Vega’s implementations:</p><ul><li>expo-image — missing support for .svg files; partially replaced with react-native-svg,</li><li>expo-image-manipulator — implemented as a legacy version; it requires the use of a legacy API,</li><li>expo-media-library — currently doesn’t support Vega; replaced with expo-file-system,</li><li>expo-router — currently doesn’t support Vega; replaced with react-navigation.</li></ul><p>To address these issues with minimal code changes, we took a TV-like approach: introducing the .kpl extension for Vega-specific files and configuring Metro to resolve them in the correct order, as shown in the example below:</p><pre>// vega/metro.config.js<br>const config = {<br>  // ...other configs...<br>  resolver: {<br>    // ...other configs...<br>    sourceExts: [<br>      ...(defaultConfig.resolver.sourceExts || []).map((ext) =&gt;<br>       `kpl.${ext}`),<br>      ...(defaultConfig.resolver.sourceExts || []),<br>    ],<br>  },<br>};</pre><p>By prioritizing the .kpl extension, Metro resolves .kpl files before standard ones, allowing Vega-specific code to remain in separate files for easier development and maintenance, without affecting the code for other platforms.</p><p>Now, we‘ll briefly review the solutions applied to each of the previously mentioned packages.</p><h4>Loading SVG files</h4><p>Instead of loading SVG images directly with the &lt;ExpoImage /&gt; component, we created a wrapper component: &lt;SvgImage /&gt;. Using our file resolution approach, it behaves differently on Vega, reading SVGs as strings via expo-file-system and rendering them with &lt;SvgXml /&gt; from the react-native-svg package. On other platforms, we still use &lt;ExpoImage /&gt;.</p><h4>Image manipulation</h4><p>To fix the incompatible expo-image-manipulator version issue, we simply created a <a href="https://github.com/software-mansion-labs/swm-react-native-labs-swm-photos/blob/episode-3/src/utils/calculateNewCachePhoto/calculateNewCachePhoto.kpl.ts">separate implementation</a> within the appropriate .kpl file. This Vega-specific implementation uses a legacy manipulateAsync() function, which serves as the interface for the Vega-supported image manipulator version.</p><h4>Media library</h4><p>Since Vega currently doesn’t provide support for expo-media-library, we added a separate, <a href="https://github.com/software-mansion-labs/swm-react-native-labs-swm-photos/blob/episode-3/src/providers/MediaLibraryPhotosProvider/useMediaLibraryPhotos.kpl.ts">Vega-specific code</a>, which uses bare expo-file-system to mimic the behavior of the media library. We implemented basic logic for filtering image and media files, as shown in the example below:</p><pre>// useMediaLibraryPhotos.kpl.ts<br>import * as FileSystem from &quot;expo-file-system&quot;<br><br>// ...other code...<br>const PHOTOS_DIR = &quot;/pkg/assets/photos&quot;;<br>const IMAGE_EXT = [&quot;jpg&quot;, &quot;jpeg&quot;, &quot;png&quot;, &quot;webp&quot;];<br><br>const entries = await FileSystem.readDirectoryAsync(PHOTOS_DIR);<br>const images = entries.filter(name =&gt; {<br>  const ext = name.split(&#39;.&#39;).pop()?.toLowerCase();<br>  return !!ext &amp;&amp; IMAGE_EXT.includes(ext);<br>});<br>// ...other code...</pre><p>To populate a device with photos, the images are packaged with the app binaries during the build and deployed to the device, where they become available at /pkg/assets inside the Vega sandbox. To automate this, we added the functionality to our <a href="https://github.com/software-mansion-labs/swm-react-native-labs-swm-photos/blob/episode-3/kepler/kepler-install.ts">installation script</a>.</p><h4>Navigation</h4><p>Similar to our earlier solutions, we replaced the unsupported expo-router with react-navigation components inside the .kpl files, following the same wrapper pattern used for loading SVG images. You can check the implementations by exploring the <a href="https://github.com/software-mansion-labs/swm-react-native-labs-swm-photos/tree/episode-3/src/components/navigation"><em>navigation tab</em></a> of our code base.</p><h4>Build and run</h4><p>To build the app for Vega, navigate to the /vega subdirectory and follow the instructions outlined in the previous build and run section of this article.</p><h3>The takeaway</h3><p>With Vega, you can take React Native’s multiplatform capabilities even further, reaching a new generation of Amazon smart devices with remote control, voice navigation, and many more upcoming features. This article aims to provide all the essential knowledge to get started with Vega development and build multifunctional apps, using our Photos Gallery example as a guide.</p><p>If you’d like to try out our app, check out <a href="https://github.com/software-mansion-labs/swm-react-native-labs-swm-photos/tree/episode-3">the code repository</a> and explore it on your Vega device. We’d love for you to share your insights and join us on the journey of expanding what’s possible with React Native!</p><p><strong>Need help with your Vega app or want to develop a new app? You can always reach out to us at </strong><a href="/service/mailto:projects@swmansion.com"><strong>projects@swmansion.com</strong></a><strong>. As the official Vega-supported agency and a long-time Amazon partner, we’ll be happy to use our first-hand experience to help you!</strong></p><p>We’re <a href="https://swmansion.com/">Software Mansion</a>: multimedia experts, AI explorers, React Native core contributors, community builders, and software development consultants.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f015e9272aed" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swmansion/react-native-for-vega-recreating-apple-google-photos-in-rn-part-3-f015e9272aed">React Native for Vega: Recreating Apple &amp; Google Photos in RN — Part 3</a> was originally published in <a href="https://medium.com/swmansion">Software Mansion</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Native Multiplatform: Recreating Apple & Google Photos in React Native — Part 2]]></title>
            <link>https://medium.com/swmansion/react-native-multiplatform-recreating-apple-google-photos-in-react-native-part-2-832398eb0d4c?source=rss-78e73e572503------2</link>
            <guid isPermaLink="false">https://medium.com/p/832398eb0d4c</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[react-native-on-tv]]></category>
            <dc:creator><![CDATA[Bartłomiej Bukowski]]></dc:creator>
            <pubDate>Fri, 12 Sep 2025 13:32:42 GMT</pubDate>
            <atom:updated>2025-09-12T13:38:54.826Z</atom:updated>
            <content:encoded><![CDATA[<h3>React Native Multiplatform: Recreating Apple &amp; Google Photos in React Native — Part 2</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O63CmAlj5tb2UInrRQHvRQ.png" /></figure><p><strong>We’re back with the second article in our Apple Photos series, diving into the next set of challenges on the way to building a multiplatform photo-gallery app.</strong></p><p>In the previous article, we walked through basic aspects of <a href="https://blog.swmansion.com/react-native-image-list-recreating-apple-google-photos-in-react-native-part-1-7f73fb74fc63">creating an efficient photo gallery list</a>, focusing on different ways to optimize image loading and rendering.</p><p>This time, <strong>we’re taking our app to the big screen. We’ll show you how to adapt it for modern TV platforms — including tvOS, AndroidTV and Amazon Fire TV,</strong> covering critical aspects of both configuration and design. We’ll also show you how to combine mobile and web support in React Native, creating a truly cross-platform app that supports all the major platforms with a single codebase.</p><p>So, without further ado, let’s dive in!</p><p>P.S. If you’d rather watch, check out our YouTube episode, where we walk you through the process in this article and <a href="http://medium.com/r?url=https%3A%2F%2Fgiolaq.dev%2F">Giovanni Laquidara</a> from Amazon shares some extra design insights:</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dc9GNmT3_ZPA&amp;type=text%2Fhtml&amp;schema=google&amp;display_name=YouTube&amp;src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fc9GNmT3_ZPA" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/f5d602ad888a9440230b34701e10bddb/href">https://medium.com/media/f5d602ad888a9440230b34701e10bddb/href</a></iframe><h3>From mobile to (Fire) TV</h3><p>When moving a React Native app from mobile to TV platforms, there are a few important things to address:</p><ul><li>proper configuration to ensure TV compatibility</li><li>design adjustments with a strong focus on remote control navigation</li><li>technical challenges caused by limited library support.</li></ul><p>Today, we’ll cover how to tackle common issues across all three areas, using Fire TV as our main example while also looking at tvOS and Android TV to highlight key differences between the platforms.</p><h3>Configuration aspects</h3><p>React Native is mainly designed for Android and iOS, and its support for TV platforms is still limited — especially around handling remote inputs and providing TV-specific components. Still, thanks to its flexibility, there are forks that extend its core functionality to include other <a href="https://reactnative.dev/docs/out-of-tree-platforms">Out-of-Tree Platforms</a><strong>.</strong></p><p>The <a href="https://github.com/react-native-tvos/react-native-tvos">react-native-tvos</a>fork enhances React Native with the features required for Apple TV and Android TV, making it possible to adapt mobile applications to TV environments. To use it, you’ll need to specify the correct dependency in thepackage.json file:</p><pre>&quot;react-native&quot;: &quot;npm:react-native-tvos@latest&quot;,</pre><p>Because <a href="https://github.com/react-native-tvos/react-native-tvos">react-native-tvos</a> is a fork of basic <a href="https://github.com/facebook/react-native">react-native</a>, it provides full compatibility with both Android and iOS, so no separate configuration is necessary.</p><p>When working with an Expo project, in addition to <a href="https://github.com/react-native-tvos/react-native-tvos">react-native-tvos</a>, you should use the <a href="https://www.npmjs.com/package/@react-native-tvos/config-tv">@react-native-tvos/config-tv</a> plugin, as <a href="https://docs.expo.dev/guides/building-for-tv/#integration-with-an-existing-expo-project">described in the official Expo docs.</a> It automatically configures Android and iOS projects for TV by modifying native files, removing unsupported dependencies, and adding the necessary assets for TV platforms.</p><p>To add the plugin to your Expo project, run the following command in your terminal:</p><pre>npx expo install @react-native-tvos/config-tv - - dev</pre><p>You should also ensure that the plugin is present in the app.json/app.config.ts file:</p><pre>export default {<br>  expo: {<br>    plugins: [&quot;@react-native-tvos/config-tv&quot;]<br>  }<br>}</pre><p>You can activate the plugin either by explicitly setting the &quot;isTV&quot;: true plugin parameter or by using the EXPO_TV=1 environment variable, which should be set during the prebuild phase. This last option is actually the most flexible, since it lets you use the same configuration for both mobile and TV platforms:</p><pre>EXPO_TV=1 expo prebuild<br>EXPO_TV=1 expo start</pre><p>To run your app specifically on Amazon Fire TV, ensure it’s built with the appropriate SDK version. According to<a href="https://developer.amazon.com/docs/fire-tv/getting-started-developing-apps-and-games.html"> Amazon’s developer documentation</a>, the minimum SDK requirements depend on the specific Fire OS version:</p><ul><li>Fire OS 5: Based on Android 5.1 (Lollipop, API level 22)</li><li><a href="https://developer.amazon.com/docs/fire-tv/fire-os-6.html">Fire OS 6</a>: Based on Android 7.1 (Nougat, API level 25)</li><li><a href="https://developer.amazon.com/docs/fire-tv/fire-os-7.html">Fire OS 7</a>: Based on Android 9 (Pie, API level 28)</li></ul><p>In an Expo project, you can set the target SDK by configuring the app.json/app.config.ts file:</p><pre>export default {<br>  expo: {<br>    android: {<br>      targetSdkVersion: 34<br>    }<br>  }<br>}</pre><h3>TV-specific development</h3><p>Developing applications for TV platforms often requires specific code to handle features such as responsive layouts or TV-specific components. In this context, the Plaform.isTV flag is essential to determine if the app is running on a TV device. By using it, you can define TV-specific code blocks, as shown below:</p><pre>if (Platform.isTV) {<br>   return (<br>     &lt;TouchableOpacity onPress={pressWrapper}&gt;<br>       {children}<br>     &lt;/TouchableOpacity&gt;<br>   );<br> }</pre><p>If you need more advanced TV-specific customizations, you can take advantage of platform-specific file extensions like tv.ts and tv.tsx to override the default implementations on tvOS and Android TV. To ensure .tv.ts and .tv.tsx files are resolved automatically, configure Metro to recognize them as platform-specific extensions:</p><pre>// metro.config.js<br><br>if (process.env.EXPO_TV) {<br> config.resolver.sourceExts = [<br>   ...(config.resolver.sourceExts || []).map((ext) =&gt; <br>  `tv.${ext}`),<br>   ...(config.resolver.sourceExts || []),<br> ];<br>}</pre><p>Note that by specifying TV extensions first, you can force Metro to resolve and load .tv.ts and .tv.tsx files instead of their generic counterparts.</p><h4>Library support overview</h4><p>All major TV platforms — including Android TV, Fire TV, and tvOS — support most common React Native and Expo libraries, although there are some exceptions.</p><p>For example, the <a href="https://docs.expo.dev/versions/latest/sdk/imagemanipulator/">expo-image-manipulator</a> library works for image downscaling on mobile builds of our app but isn’t supported on tvOS.</p><p>To check the compatibility of a given library with your desired TV platform, visit <a href="https://reactnative.directory/">https://reactnative.directory</a>, and enable TV platforms filters (tvOS or Works with FireOS).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FvV2YkErlf6XecpQG8Xy8g.png" /></figure><h3>Design aspects</h3><p>One of the main challenges when adapting an app for TV platforms is supporting remote control navigation. This involves managing focus correctly and handling remote-specific actions. There are a few ways to approach this:</p><h4>Touchable elements</h4><p>With <a href="https://github.com/react-native-tvos/react-native-tvos">react-native-tvos</a>, touchable elements automatically receive focus when navigated with the D-pad or arrow keys, and trigger onPress when the user confirms with the select/enter button. The main advantage of this approach is that it works across all major TV platforms, and doesn’t require a separate code for mobile platforms, since touchable elements are native to both Android and iOS.</p><p>In this section, we’re going to focus specifically on the <a href="https://reactnative.dev/docs/touchableopacity">TouchableOpacity</a> component as an example.</p><p><a href="https://reactnative.dev/docs/touchableopacity">TouchableOpacity</a> provides a set of TV-specific props for handling remote controller actions. The most important ones are:</p><ul><li><a href="https://reactnative.dev/docs/touchableopacity#hastvpreferredfocus-ios">hasTVPreferredFocus</a> — sets an initial focus when the screen loads.</li><li><a href="https://reactnative.dev/docs/touchablewithoutfeedback#onfocus">onFocus</a>/<a href="https://reactnative.dev/docs/touchablewithoutfeedback#onblur">onBlur</a> — handles focus change events for UI feedback.</li><li><a href="https://reactnative.dev/docs/touchablewithoutfeedback#onpress">onPress</a> — triggered when the user confirms their choice.</li><li><a href="https://reactnative.dev/docs/touchableopacity#nextfocusup-android">nextFocusUp</a> / <a href="https://reactnative.dev/docs/touchableopacity#nextfocusdown-android">nextFocusDown</a> / <a href="https://reactnative.dev/docs/touchableopacity#nextfocusleft-android">nextFocusLeft</a> / <a href="https://reactnative.dev/docs/touchableopacity#nextfocusright-android">nextFocusRight</a> — defines directional navigation on Fire TV / Android TV.</li><li><a href="https://github.com/react-native-tvos/react-native-tvos/blob/release-0.81.1-3/packages/react-native/Libraries/Components/TV/TVViewPropTypes.js#L79">tvParallaxProperties</a> – configures the parallax effect on tvOS.</li></ul><p>The code below provides a simple example of how to use <a href="https://reactnative.dev/docs/touchableopacity">TouchableOpacity</a>. You can also check out <a href="https://github.com/software-mansion-labs/swm-react-native-labs-swm-photos/blob/main/src/components/image/FocusableImage.tsx">this example</a> from our app, where <a href="https://reactnative.dev/docs/touchableopacity">TouchableOpacity</a> wraps a focusable image component.</p><pre>&lt;TouchableOpacity<br>  hasTVPreferredFocus<br>  onFocus={() =&gt; setHighlight(true)}<br>  onBlur={() =&gt; setHighlight(false)}<br>  onPress={() =&gt; handleSelect()}<br>  nextFocusRight={nextRef}<br>  tvParallaxProperties={{ enabled: true }}<br>&gt;<br>  &lt;Text&gt;Play&lt;/Text&gt;<br>&lt;/TouchableOpacity&gt;</pre><p>Touchable elements provide sufficient functionality to handle simple navigation in our Photos Gallery app. However, if you’re looking for a more extensive and future-proof way to handle touch-based input, check out the <a href="https://reactnative.dev/docs/pressable">Pressable API</a>.</p><h4>react-tv-space-navigation</h4><p><a href="https://github.com/bamlab/react-tv-space-navigation">react-tv-space-navigation</a> helps manage TV remote focus by maintaining a virtual focus tree for LRUD (Left, Right, Up, Down) navigation across nested React components. It dynamically updates focus targets as elements mount or change, restores focus to the last focused child, automatically scrolls containers to keep the focused item visible, and skips over non-focusable elements.</p><p>Key components of <a href="https://github.com/bamlab/react-tv-space-navigation">react-tv-space-navigation</a>:</p><ul><li><a href="https://github.com/bamlab/react-tv-space-navigation/blob/main/docs/api.md#spatialnavigationroot">SpatialNavigationRoot</a> – the top-level provider that manages focus state and navigation logic for the entire app.</li><li><a href="https://github.com/bamlab/react-tv-space-navigation/blob/main/docs/api.md#spatialnavigationview">SpatialNavigationView</a> – defines a focusable container with a navigation direction (horizontal<strong> </strong>or vertical), grouping related focusable elements and managing their LRUD behavior.</li><li><a href="https://github.com/bamlab/react-tv-space-navigation/blob/main/docs/api.md#spatialnavigationfocusableview">SpatialNavigationFocusableView</a> – a focusable element that responds to focus and select events and is automatically included in the navigation tree.</li><li><a href="https://github.com/bamlab/react-tv-space-navigation/blob/main/docs/api.md#spatialnavigationscrollview">SpatialNavigationScrollView</a> – a scrollable container that keeps the focused item visible by automatically scrolling when needed.</li></ul><p>For a detailed example, take a look at <a href="https://github.com/AmazonAppDev/react-native-multi-tv-app-sample">the sample project</a> in Amazon’s official repository. It covers common use cases, like setting up remote control navigation for lists and side panels.</p><h4>TVFocusGuideView</h4><p><a href="https://github.com/react-native-tvos/react-native-tvos/blob/release-0.81.3-0/README.md?plain=1#L280">TVFocusGuideView</a> offers another way to manage focus navigation between focusable elements when using a remote controller. It creates an invisible focus guide that redirects focus to specified targets when the user navigates beyond an element’s bounds (for example, by pressing the remote’s arrow keys). The component includes a set of specialized, easy-to-use properties like <a href="https://github.com/react-native-tvos/react-native-tvos/blob/release-0.81.3-0/README.md?plain=1#L285">autoFocus</a>, <a href="https://github.com/react-native-tvos/react-native-tvos/blob/release-0.81.3-0/README.md?plain=1#L287">trapFocus</a>, and <a href="https://github.com/react-native-tvos/react-native-tvos/blob/7b853e7cfb77932468ac124b732c10fd39e81280/README.md?plain=1#L284">destinations</a>. For a detailed look at <a href="https://github.com/react-native-tvos/react-native-tvos/blob/release-0.81.3-0/README.md?plain=1#L280">TVFocusGuideView</a> and its props, check out <a href="https://dev.to/amazonappdev/tv-navigation-in-react-native-a-guide-to-using-tvfocusguideview-302i">this article</a> or the example code below:</p><pre>// When the empty &lt;View&gt; inside can&#39;t be focused the focus is redirected<br>&lt;TVFocusGuideView destinations={[button2Ref, button3Ref]}&gt;<br>   // TVFocusGuideView will guide the focus towards button2 or button3<br>  &lt;View style={{ width: 100, height: 100 }} /&gt;<br>&lt;/TVFocusGuideView&gt;<br>      <br>&lt;Button ref={button2Ref} title=&quot;Button 2&quot; onPress={() =&gt; {}} /&gt;<br>&lt;Button ref={button3Ref} title=&quot;Button 3&quot; onPress={() =&gt; {}} /&gt;</pre><h4>Responsiveness</h4><p>When building TV apps with React Native, keep in mind that different TV platforms support different screen resolutions and DPIs. Fire TV and Android TV can use various DPIs and resolutions, e.g., 960×540 or higher, while tvOS (Apple TV) typically uses higher resolutions like 1920×1080 or above. Even though your app doesn’t need to be responsive at runtime — since TV screens don’t resize like a browser window — the UI should still scale properly across different resolutions, DPIs, and device types.</p><p>To do this, use relative scaling based on the screen height, as shown in the example below:</p><pre>const resolution = Dimensions.get(&quot;window&quot;);<br><br>// Factory function to create a scaler based on a design preset<br>const createScaler = (designPreset) =&gt; {<br>  // Calculate scaling factor as ratio of actual window height to design preset height<br>  const scale = resolution.height / designPreset.height;<br><br>  // Return a function that scales a given size by the calculated factor<br>  return (size) =&gt; size * scale;<br>};<br><br>const scaledPixels = createScaler(fullHDPreset);<br><br>// Now you can easily define scaled styles<br>const styles = StyleSheet.create({<br>  textStyle: {<br>    fontSize: scaledPixels(14),<br>    marginBottom: scaledPixels(10)<br>  }<br>});</pre><h3>Adding web support</h3><p>Moving a React Native app from mobile to the web brings a few key differences and challenges: no access to the native filesystem, limited support for mobile-specific libraries, and variations in pixel density and how screens resize.</p><p>To address this, we use <a href="https://necolas.github.io/react-native-web/docs/">react-native-web</a> to ensure proper bundling and support for React Native components in a web environment. Together with Expo, this offers a straightforward way to build and run the app on the web. However, we’ll need to take a few extra steps to maintain all the functionality of the app’s mobile version.</p><h4>Accessing photos</h4><p>Currently there is no web support for <a href="https://docs.expo.dev/versions/latest/sdk/media-library/">expo-media-library</a> and <a href="https://docs.expo.dev/versions/latest/sdk/filesystem/">expo-filesystem</a> which are crucial for loading image data in our mobile photo gallery app. So, one possible solution is to implement a custom backend API to handle file operations on the server side. However, relying on a backend API while mobile apps store photos locally can create inconsistencies in storage logic, requiring separate implementations for web and mobile and making development and testing more complicated.</p><p>An alternative is to access files from the local filesystem through the browser. Fortunately, modern browsers offer several ways to do this, with <a href="https://developer.chrome.com/docs/capabilities/web-apis/file-system-access"><strong>File System Access API</strong></a>. This API allows users to select a directory, which therefore can be accessed by the browser, allowing it to read and/or modify contained files. It’s also the main solution we’ll focus on in the next part of this article.</p><h4>File System Access API</h4><p><a href="https://wicg.github.io/file-system-access/">File System Access API</a> lets web apps running in supported browsers interact directly with the user’s filesystem. The API uses asynchronous iterators and permission-based file handles, enabling it to efficiently work with large sets of files without needing upload inputs.</p><p>The main features of this API are provided through the following functions:</p><ul><li><a href="https://wicg.github.io/file-system-access/#api-showdirectorypicker">window.showDirectoryPicker()</a> – an asynchronous method that opens a directory picker so the user can select a folder; it returns a <a href="https://wicg.github.io/file-system-access/#api-filesystemdirectoryhandle">FileSystemDirectoryHandle</a>.</li><li><a href="https://fs.spec.whatwg.org/#api-filesystemdirectoryhandle-asynciterable">directoryHandle.values()</a> – an async iterator over the directory’s entries, providing name-handle pairs for files and subdirectories.</li><li><a href="https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/getFile">fileHandle.getFile()</a> – retrieves a File object from the file handle.</li><li><a href="https://w3c.github.io/FileAPI/#text-method-algo">file.text()</a> – reads the file’s text content.</li></ul><p>For a complete overview of the API’s functionality and implementation, you can visit the <a href="https://developer.mozilla.org/en-US/docs/Web/API/File_System_API">documentation</a> or the <a href="https://developer.chrome.com/docs/capabilities/web-apis/file-system-access">chrome for developers’ blogpost</a>.</p><p>The example below shows the basic use of File System Access API, including selecting a directory and reading files from it:</p><pre>async function loadDirectory(): Promise&lt;void&gt; {<br>  try {<br>    // Prompt user to select a directory<br>    const dirHandle = await window.showDirectoryPicker({mode: &quot;read&quot;});<br>    <br>    // Iterate through the available files - iterators are async<br>    for await (const [name, handle] of dirHandle.entries()) {<br>      if (handle.kind === &quot;file&quot;) {<br>        const file = await handle.getFile();<br><br>        // Process file<br>        // ...<br>      }<br>      else if (handle.kind === &quot;directory&quot;) {<br>        // Process subdirectory<br>        // eg. Recursively search for files from the subdirectory<br>        // ...<br>      }<br>    }<br>  } catch (err) {<br>    // Handle any errors during directory selection phase<br>    // eg. If API is not supported by your browser<br>    // ...<br>  }<br>}</pre><p>For a more detailed example, you can check out <a href="https://github.com/software-mansion-labs/swm-react-native-labs-swm-photos/blob/main/src/providers/MediaLibraryPhotosProvider/filesystem/filesystem.web.ts">implementation</a> and <a href="https://github.com/software-mansion-labs/swm-react-native-labs-swm-photos/blob/main/src/app/index.web.tsx">usage</a> of the API in our public repository.</p><p>File System Access API is supported by most modern browsers, including Chrome and Edge. However, some browsers, like Firefox, don’t support it. In the next part of this article, we’ll show a fallback solution to handle these cases.</p><p>To check the compatibility of File System Access API with your browser, you can visit <a href="https://caniuse.com/?search=File%20System%20Access%20API">caniuse.com website</a>.</p><h4>Webkitdirectory API</h4><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory">webkitdirectory</a> is a file input attribute that lets users select an entire folder instead of individual files, enabling all files within that folder and its subdirectories to be uploaded at once. Unlike File System Access API, <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory">webkitdirectory</a> only allows selecting and uploading a folder with its contents — it doesn’t let you modify files. However, because it’s supported by a <a href="https://caniuse.com/?search=webkitdirectory">wider range of browsers</a>, it can serve as a fallback when File System Access API isn’t available.</p><p>Below is an example showing how to use <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory">webkitdirectory</a> to load and display files from a selected directory:</p><pre>function WebkitShowcaseComponent() {<br>  // A reference used to trigger the input element<br>  const inputRef = useRef&lt;HTMLInputElement&gt;(null);<br><br>  // Some other React component logic<br>  // ...<br><br>  return (<br>    &lt;&gt;<br>      &lt;Button onPress={() =&gt; inputRef.current?.click()} /&gt;<br>      &lt;input<br>        type=&quot;file&quot;<br>        webkitdirectory=&quot;&quot;  // Allows to select the entire directory<br>        multiple    // Allows to select multiple files <br>        accept=&quot;image/*&quot;  // A filter for selected directory<br>        ref={inputRef}<br>        onChange={(e) =&gt; console.log(e.target.files)}  // Access files<br>      /&gt;<br>    &lt;/&gt;<br>  );<br>}</pre><p>You can learn more from <a href="https://github.com/software-mansion-labs/swm-react-native-labs-swm-photos/blob/main/src/app/index.web.tsx">our repository</a>.</p><h4>Persisting directory with <a href="https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API">IndexedDB</a></h4><p>While both APIs offer a convenient way to access files from the local filesystem, they rely on the user selecting the desired directory each time. Requiring this on every app reload would hurt the user experience, so it’s important to persist the selected directory throughout the app’s lifecycle.</p><p>We can achieve it using <a href="https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API"><strong>IndexedDB</strong></a> — a low-level, client-side storage API for storing significant amounts of structured data in the browser. It lets web applications create, read, update, and delete objects within a transactional database, enabling offline access and efficient querying of large datasets.</p><p>In our photo gallery app, we store the directory handle in <a href="https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API">IndexedDB</a>, making it easy to reload the directory’s content whenever needed. The full code is available <a href="https://github.com/software-mansion-labs/swm-react-native-labs-swm-photos/blob/main/src/providers/MediaLibraryPhotosProvider/filesystem/storage.web.ts">here</a>.</p><h4>Adapting the layout</h4><p>One unique aspect of the web, compared to mobile or TV platforms, is the wide variety of window sizes, since users can easily resize their browser. This, however, brings the additional challenge of creating a fully responsive user interface.</p><p>A specific example of this issue arises when using <a href="https://reactnative.dev/docs/dimensions#get">Dimensions.get(&#39;window&#39;)</a> in a web environment: it returns the window’s dimensions only at the initial render and doesn’t update when the browser is resized. To solve this, we can use the <a href="https://reactnative.dev/docs/usewindowdimensions">useWindowDimensions()</a> hook, which updates automatically whenever the window size changes. To prevent unnecessary rerenders, we’ll wrap the hook inside a global context provider, as shown in the example below:</p><pre>// WindowDimensionsProvider.tsx<br>const WindowDimensionsContext = createContext(undefined);<br><br>const WindowDimensionsProvider({children}: PropsWithChildren) =&gt; {<br>  const dimensions = useWindowDimensions();<br>  <br>  return (<br>    &lt;WindowDimensionsContext.Provider value={dimensions} &gt;<br>      {children}<br>    &lt;/WindowDimensionsContext.Provider&gt;<br>  );<br>}</pre><p>Wrapping the entire app in this context provider ensures that the current window size is tracked and triggers re-renders whenever necessary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*aVasRLIEQLJyTqm36Q8S4g.gif" /><figcaption><em>App responsiveness before and after implementing </em><em>useWindowDimensions().</em></figcaption></figure><h3>The takeaway</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*k-yhsbX_YUoU-XQM6Lu2Dg.gif" /><figcaption><em>As you can see, our photo gallery app runs smoothly across different devices.</em></figcaption></figure><p>React Native lets you build apps for multiple platforms, including TVs like Fire TV, Android TV, and tvOS, as well as the web and other devices. In this article, we’ve gone over the key steps to prepare your app for these environments and ensure a consistent user experience across platforms.</p><p>If you’d like to see our photo gallery app in action, check out the <a href="https://github.com/software-mansion-labs/swm-react-native-labs-swm-photos">code repository</a>. Try the app on different platforms, share your observations in the comments, and let’s keep growing the React Native ecosystem together!</p><p><strong>Huge thanks to Igor Swat and </strong><a href="https://giolaq.dev/"><strong>Giovanni Laquidara</strong></a><strong> for all their contributions to this project!</strong></p><p>We’re <a href="https://swmansion.com/">Software Mansion</a>: multimedia experts, AI explorers, React Native core contributors, community builders, and software development consultants.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=832398eb0d4c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swmansion/react-native-multiplatform-recreating-apple-google-photos-in-react-native-part-2-832398eb0d4c">React Native Multiplatform: Recreating Apple &amp; Google Photos in React Native — Part 2</a> was originally published in <a href="https://medium.com/swmansion">Software Mansion</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Native Image List: Recreating Apple & Google Photos in React Native — Part 1]]></title>
            <link>https://medium.com/swmansion/react-native-image-list-recreating-apple-google-photos-in-react-native-part-1-7f73fb74fc63?source=rss-78e73e572503------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f73fb74fc63</guid>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Bartłomiej Bukowski]]></dc:creator>
            <pubDate>Tue, 15 Jul 2025 15:32:08 GMT</pubDate>
            <atom:updated>2025-07-15T16:07:37.311Z</atom:updated>
            <content:encoded><![CDATA[<h3>React Native Image List: Recreating Apple &amp; Google Photos in React Native — Part 1</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R6W5FdoqGzVNEsgR2wE1Fw.png" /></figure><p><strong>This is the first article in our deep dive series, where we’ll walk you through building a high-performance photo list like Apple or Google Photos using just React Native. We’ve also published a </strong><a href="https://www.youtube.com/watch?v=tzpULSNg1Js"><strong>video walkthrough</strong></a><strong> and a </strong><a href="https://github.com/software-mansion-labs/swm-react-native-labs-swm-photos"><strong>public GitHub repo</strong></a><strong> so you can explore the code and try it out on your own device.</strong></p><p><strong>This part focuses on two key steps:</strong></p><ul><li><strong>Loading all available photos from the device</strong></li><li><strong>Plugging them into a scrollable list component for easy browsing</strong></li></ul><p><strong>So, let’s dive in and explore the best practices for speed and top user experience.</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DtzpULSNg1Js&amp;type=text%2Fhtml&amp;schema=google&amp;display_name=YouTube&amp;src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FtzpULSNg1Js" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/bd9c79820865373a6f47b459d8ee74bb/href">https://medium.com/media/bd9c79820865373a6f47b459d8ee74bb/href</a></iframe><h3>References: Apple Photos and Google Photos</h3><p>So, since we want to build a fast and smooth photo gallery in React Native, let’s take a look at how the market leaders do it.</p><p>Both iOS and Android photo apps are great examples of strong performance — it’s not because such an effect can only be achieved with native implementations. It’s because of the smart optimizations they do ahead of time.</p><p>Google Photos does two key things to optimize performance:</p><ul><li>The app indexes the phone’s photo gallery during the very first launch. When you open it for the very first time, you can notice a processing indicator and an increasing number of photos found on the device.</li><li>When you’re actually scrolling through the photo list, you can observe that each image initially appears in low resolution, and then swiftly loads in higher resolution:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/0*RSYJEEgo7Dd4sqWz" /></figure><p>In contrast, iOS optimizes and gathers information about photos in the background, even before you open Apple Photos. You can notice it e.g., when you migrate to a new device. Alternatively, you can trigger this background processing effect when you transfer a large number of images to the gallery by hand:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/0*zhSB4Yu-VF2zUFHw" /></figure><p>Some of these optimization techniques can also be applied to our React Native implementation. So, we’re going to combine these techniques with React Native libraries to recreate Apple and Google Photos.</p><p>We’ll be testing our app on the following devices:</p><ul><li>iPhone 13 mini (iOS 18.5)</li><li>iPhone 16 (iOS 18.5)</li><li>Pixel 9 Pro (Android 16)</li><li>Pixel 4a (Android 13)</li></ul><p>We seed each device with 2,100 high-resolution photos using the script from the repository. This gives us 7 different images, each duplicated 300 times. The photo resolutions range from 3872×2592 up to 7372×4392 pixels.</p><h3>Step 1: Loading images from the device (batching &amp; caching)</h3><p>Efficient image loading is the first step toward building a performant list. On Android, reading the entire MediaLibrary in one go takes about 9 seconds on a Pixel 9 and 16.5 seconds on a Pixel 4a. On iOS, it’s significantly faster — averaging just 0.1 seconds on both devices we’ve tested.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7860ecb455c98f09ee0f3d47df15368e/href">https://medium.com/media/7860ecb455c98f09ee0f3d47df15368e/href</a></iframe><p>Such long loading times on Android devices can have a negative impact on UX and we aim to ensure our app’s perceived performance is top-notch. That’s why it’s crucial to implement strategies to speed up the time it takes to render the first photo.</p><p><strong>One of the effective approaches to do so is batching. </strong>Rather than loading all images at once, we fetch them in smaller chunks. This cuts down the initial load time and lets us display photos to the user much faster.</p><p>For this purpose, we use the <a href="https://docs.expo.dev/versions/latest/sdk/media-library/">expo-media-library</a> to access the device’s images and implement batching to fetch them in manageable chunks. This helps display the first set of photos much faster.</p><pre>const LOAD_BATCH_SIZE = 50;<br>let hasNextPage = true;<br>let endCursor: string | undefined = undefined;<br>let photos: MediaLibraryPhoto[] = [];<br><br>while (hasNextPage) {<br>  const newBatch = await MediaLibrary.getAssetsAsync({<br>    first: LOAD_BATCH_SIZE,<br>    after: endCursor,<br>    mediaType: &quot;photo&quot;,<br>    sortBy: [[&quot;modificationTime&quot;, true]],<br>  });<br><br>  setAssets((prev) =&gt; [...prev.assets, ...newBatch.assets]);<br><br>  hasNextPage = newBatch.hasNextPage;<br>  endCursor = newBatch.endCursor;<br>}</pre><p>Another technique is caching the data we receive from the device. We use <a href="https://github.com/mrousavy/react-native-mmkv">react-native-mmkv</a> to power our caching layer. On subsequent app launches, we load the cached photo data first and then asynchronously compare it with the current photos on the device to keep everything up to date.</p><blockquote>Side note: we’ve been curious why Android loading times are this much longer than the ones on iOS. We’ve investigated and we’ve proposed some improvements. You can learn more about it in this <a href="https://github.com/expo/expo/pull/37957">GitHub Pull Request</a>.</blockquote><h3>Step 2: From &lt;Image&gt; to Expo Image</h3><p>React Native’s built-in &lt;Image&gt; component works fine for basic needs, but if you want better performance and more features, Expo Image is a great alternative.</p><p>We’ve compared these components when trying to load 200 full-resolution images into a 5-column grid, and here are our findings:</p><p>We tried to measure loading times per image by comparing the timestamp reported between onLoadStart and onLoadEnd callbacks.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f00493cf1f85d068eff6f662e38cb35/href">https://medium.com/media/7f00493cf1f85d068eff6f662e38cb35/href</a></iframe><p><strong>Also, we’ve inspected the memory consumption:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/96a9636cc674f54ebf05d429cb71dd76/href">https://medium.com/media/96a9636cc674f54ebf05d429cb71dd76/href</a></iframe><p><strong>On iOS:</strong></p><ul><li>The default &lt;Image&gt; component loads images up to 25 times faster than Expo Image. 😱</li><li>Expo Image crashes if too many images load at once due to high memory use, so we had to limit the number to 60 instead of 200 for testing.</li><li>The initial image load with Expo Image causes a memory spike, reaching around 1.53 GB.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*W4AWwcLJv1-FV1PO" /></figure><blockquote>We consulted with the Expo team regarding these iOS issues and were able to significantly improve the package. You can learn more about the improvements in GitHub Pull Requests <a href="https://github.com/expo/expo/pull/37795">#37795</a>, <a href="https://github.com/expo/expo/pull/37979">#37979</a>, <a href="https://github.com/expo/expo/pull/37987">#37987</a></blockquote><p><strong>On Android, here’s what we observed:</strong></p><ul><li>Image loading was limited to about 173 images; the remaining 27 slots appeared blank on both the Pixel 4 and Pixel 9.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*MbpGDNEZG8brBsFmxi3eug.png" /></figure><ul><li>Expo Image performed better in terms of loading speed, especially on the Pixel 9, where it was twice as fast as the default &lt;Image&gt; component.</li><li>Expo Image also had a smaller memory footprint.</li></ul><p><strong>So, we’ve got a clear winner on Android — </strong>Expo Image<strong>!</strong></p><p>It’s also with mentioning that Expo Image comes with more props that let you control how images are loaded:</p><ul><li><strong>CachePolicy</strong>: Helps optimize memory and disk usage by smartly caching images, so consecutive loads of the same images takes significantly less time.</li><li><strong>Android-specific RGB decoding format</strong>: Lets you fine-tune how images are decoded on Android, which can improve rendering speed and lower memory usage.</li></ul><p>There’s also a useImage hook, which is meant to load images at the desired dimensions and keep them in memory. However, it still loads the full-resolution photo initially, which can cause the app to crash due to high memory usage.</p><p>To further improve the perceived performance and UX of the app you can also use some intermediate techniques by giving users immediate visual feedback while images are loading:</p><ul><li><strong>Placeholders</strong>: A simple static image is displayed before the actual image loads.</li><li><strong>Blurhashes</strong>: A compact way to represent an image, used to display a blurred placeholder for a smooth visual transition while the full image loads.</li><li><strong>Skeletons</strong>: Simple grey placeholders that mimic the image layout. They’re especially useful when you don’t yet have any image data (like a URL or blurhashes) but still want to show that something is loading.</li></ul><h3>Step 3: Optimizing with mipmaps</h3><p>We know that high-resolution photos — while visually appealing — aren’t necessary for the list view we’re building. All we need is a downscaled version that fits into our 5-column grid.</p><p>To handle this efficiently, <strong>we use mipmapping — a technique that pre-generates downscaled versions of images. </strong>Ideally when an image is displayed, the system automatically selects the right mipmap level based on the display size. This means a smaller, optimized version of the image is rendered in smaller views, reducing memory usage and improving rendering speed.</p><p>In our case, we only need a single mipmap per image, sized to match one cell in the gallery grid.</p><p>Although Expo Image generates mipmaps automatically, they didn’t work reliably for us on iOS. So we built our own solution.</p><p>We added another layer to our image-loading pipeline that uses ImageManipulator to generate downscaled versions of each photo. These processed images are also cached to speed up future app launches.</p><p>You can find the full implementation <a href="https://github.com/software-mansion-labs/swm-react-native-labs-swm-photos">in the repository</a>. Here’s the most important part of the code:</p><pre>const manipulatorContext = ImageManipulator.manipulate(image.uri);<br>manipulatorContext.resize({<br>  height: newSmallerHeight,<br>});<br>const optimizedImage = await manipulatorContext.renderAsync();<br>const result = await optimizedImage.saveAsync({<br>  format: SaveFormat.JPEG,<br>  compress: 0.8,<br>});<br>optimizedImage.release();</pre><p><strong>Loading times — original full-resolution images vs. downscaled images:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/af3ef18d02d1e38bbfb1152397ed7421/href">https://medium.com/media/af3ef18d02d1e38bbfb1152397ed7421/href</a></iframe><p><strong>Memory usage — original images vs. downscaled images (in MB):</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f13ee0490ce12c3092b7d8c841cff01/href">https://medium.com/media/7f13ee0490ce12c3092b7d8c841cff01/href</a></iframe><p>There are several important things to notice here:</p><ul><li>On Android, Expo Image outperforms the default &lt;Image&gt; component.</li><li>On iOS, Expo Image performs slightly worse than the default &lt;Image&gt; component when mipmaps are in the game.*</li><li>We decided that when mipmaps are included the overall gain from using Expo Image is greater than the gain we have from using the default &lt;Image&gt; component.</li></ul><blockquote>*We consulted with the Expo team regarding these iOS issues and were able to significantly improve the package. You can learn more about the improvements in GitHub Pull Requests <a href="https://github.com/expo/expo/pull/37795">#37795</a>, <a href="https://github.com/expo/expo/pull/37979">#37979</a>, <a href="https://github.com/expo/expo/pull/37987">#37987</a>. Once the next version of Expo Image is released, we expect it to outperform the default Image component on iOS as well.</blockquote><h3>Step 4: Choosing the right list component: FlatList vs. FlashList vs. LegendList</h3><p><strong>Choosing the right list component is key to building a responsive and high-performing image list in React Native. </strong>We looked at three options <a href="https://reactnative.dev/docs/performance#flatlist-rendering-is-too-slow-or-scroll-performance-is-bad-for-large-lists">recommended by the official React Native docs</a>: FlatList, FlashList, and LegendList — and we tested their performance on iOS, high-end Android, and low-end Android devices.</p><p>For a great overview of these list solutions and more about how they’re built, check out Jay Meistrich’s talk from this year’s App.js Conf:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F4nfxSE9OByQ%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D4nfxSE9OByQ&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F4nfxSE9OByQ%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/9eb16f89761cc8d207807d223e346842/href">https://medium.com/media/9eb16f89761cc8d207807d223e346842/href</a></iframe><p>Below, you can find our performance observations:</p><h4>FlatList — it’s the default list component in React Native</h4><p>It performs well on high-end devices or with smaller image sets. But on low-end Android phones, scrolling through large photo collections can cause noticeable FPS drops.</p><h4>FlashList (version 1.8.3) — it’s optimized for large datasets and delivers smoother scrolling, even on lower-end devices</h4><p>It offers smoother scrolling than FlatList, especially with large datasets. Sometimes you might see brief “whitespace” gaps during fast scrolling, but they fill in quickly.</p><h4>LegendList (version 1.1.3) — A JavaScript-only package that promises better performance, especially when handling dynamically sized items without any native dependencies</h4><p>It offers competitive performance and stands out for its pure JavaScript implementation, making cross-platform development easier by avoiding native dependencies. However, regardless of device, it often renders many blank areas during scrolling, especially when scrolling quickly.</p><p>When using downscaled versions of the photos, we’ve found that all three list solutions performed similarly.</p><p>In tests with over 2,100 high-resolution images, we compared memory usage and perceived performance. We paid close attention to any frame drops during scrolling — even during fast “rage scrolling” — as well as blank (white) areas that would appear briefly before the images load.</p><p><strong>Here’s how the memory consumption compares (in MB):</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b2fb6e8785bfb1601010ee94f9f79058/href">https://medium.com/media/b2fb6e8785bfb1601010ee94f9f79058/href</a></iframe><p>In a nutshell, we can see that FlatList uses the least memory, while FlashList uses the most. However, FlashList performs best across devices, with almost no white areas and fewer frame drops during scrolling.</p><h3>Code once, run everywhere</h3><p><strong>One of the coolest things about React Native is that you can write your code once and run it anywhere. </strong>The optimizations and techniques discussed in this article work across platforms. Our SWM Photo app is built with these in mind and is meant to run everywhere, though so far we’ve focused on mobile devices. So, stay tuned! More platforms will be coming in future articles and episodes from our series.</p><p><strong>By using these optimization techniques, you can build React Native lists that don’t just work, but feel smooth and fast — just like native apps such as Apple Photos.</strong></p><p>If you want to dig deeper, check out the <a href="https://github.com/software-mansion-labs/swm-react-native-labs-swm-photos">code repository</a>. Give it a try, run your own tests, and don’t forget to share your findings in the comments. Let’s keep making the React Native community stronger together!</p><p>Huge thanks to Robert Kozik and Jakub Kosmydel for all their contributions to this project!</p><p>We’re <a href="https://swmansion.com/">Software Mansion</a>: multimedia experts, AI explorers, React Native core contributors, community builders, and software development consultants.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f73fb74fc63" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swmansion/react-native-image-list-recreating-apple-google-photos-in-react-native-part-1-7f73fb74fc63">React Native Image List: Recreating Apple &amp; Google Photos in React Native — Part 1</a> was originally published in <a href="https://medium.com/swmansion">Software Mansion</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>