The Age of Universal React: What’s the Catch?

Rate this content
Bookmark

Web and Mobile are getting closer and closer in the React ecosystem. With the launch of Expo Router and React Strict DOM in the last year, the message is clear: Web and mobile can no longer be separated. The React Core Team and community have been working silently in the background on this project, and there have been RFCs to bring Web APIs to Native, and make the RN event loop closer to the web.This is great for developers - suddenly React devs can “learn once, write once, and run anywhere”, and can target web, iOS, and Android (and even more) from a single codebase. You might be thinking: is this just a pipe dream, and will the reality live up to the expectation of “writing once” for every platform? In this talk, we’ll share our real-world experiences of building universal React apps from a single codebase. We’ll look at the libraries and tools, cover some of the real-world challenges, and share with you a <List /> of what you can and can’t share across different platforms.  

This talk has been presented at React Day Berlin 2024, check out the latest edition of this React Conference.

FAQ

Universal React allows developers to use a single codebase for multiple platforms, reducing the need for separate teams per platform, saving costs, and enabling small teams to compete with large industry players.

Universal React combines React and React Native to target multiple platforms from a single codebase. It maintains native experiences across platforms, unlike web view apps, and allows for code sharing and reuse.

React Native Web acts as a compatibility layer that translates React Native components to web-compatible HTML and CSS, enabling cross-platform development.

Challenges include maintaining performance across platforms, especially on the web due to large bundle sizes, and ensuring compatibility with non-core platforms like Windows.

Existing apps can leverage tools like Expo DOM and React Strict DOM, along with monorepo setups to abstract shared components, gradually introducing universal code without a complete rewrite.

Universal React refers to cross-platform apps using React and React Native, encapsulating the principle 'learn once, write once, run anywhere.' It enables building apps for multiple platforms with a single codebase.

React Strict DOM is a Meta-initiated approach that emphasizes performance and accessibility by leveraging web APIs, aiming for platform agnostic development and bridging the gap between web and native.

Universal React employs styling abstractions that convert inline styles to platform-compatible styles, allowing for consistent styling across web and native applications.

The future includes advancements like React Strict DOM, which focuses on improving cross-platform performance and accessibility, along with efforts to align React Native with web standards.

Frameworks like Expo and libraries like React Native Web, Expo Router, and universal UI libraries like Tamagoyi and Gluestack facilitate universal React development.

Mo Khazali
Mo Khazali
Anisha Malde
Anisha Malde
30 min
13 Dec, 2024

Comments

Sign in or register to post your comment.
Video Summary and Transcription
We're going to talk about the age of universal React, the next paradigm shift of React. Universal React is cross-platform and follows the principle of learn once, write once, and run anywhere. React Native is born as a declarative way to build iOS and Android apps. React Native components and APIs are implemented in an interoperable way with React DOM, powering a large part of Twitter's web platform. Code sharing in a universal React app maximizes code reuse, reduces duplication, and allows platform optimization. React Native for Web is the compatibility layer that enables universal development, handling translations between React Native and React Dom. Expo is the framework of choice for React Native, with Expo Router V3 completing the universal story. Challenges in achieving parity with React Native Core due to specific platform implementations. React Strict DOM prioritizes web, bringing web APIs to React Native. Taking a universal React approach can improve performance across platforms. React Native Web and React Strict DOM prioritize performance and accessibility.

1. Introduction to Universal React

Short description:

We're going to talk about the age of universal React, the next paradigm shift of React. Mo and I met at conferences and decided to join efforts. I started as a web developer and transitioned to React Native. Now I'm a React Native developer advocate at Amazon App Store, and universal React helps us navigate the fragmented world of devices.

Folks, thank you so much for coming here. We're both incredibly excited to be with you. We're going to be talking about the age of universal React, which we think is this next paradigm shift of React. And we're incredibly excited to talk about it. We're going to be looking at the good, the bad, the ugly, and hopefully a little bit into the future.

As Antonio mentioned, my name is Mo. I head the mobile team at Theodo. I've always loved building apps. I built my first app when I was 13. So I started with native iOS, transitioned into the web world with React, and then went back to native with React Native. So I think universal React kind of encapsulates all of the things that I've done in my journey and I'm super excited for it.

Yeah, so Mo and I actually met at the many conferences we've been to and spoken at over the last few years. And we realized we were both talking about, like, very adjacent topics. Mo was talking about sharing code between React and React Native. I was talking about building for multiple devices. And so we decided, let's just join efforts and talk about universal React. Unlike Mo, I don't know what I was doing when I was 13, probably playing, I don't know, Pokemon or something. But I did start as a web developer eight years ago and I was a React developer. And then I transitioned to React Native. And I'm currently a React Native developer advocate at Amazon App Store, which is the app store that runs on our devices. So the types of apps that I work with run on phones, tablets, auto, web, TV. And universal React helps me and our developers navigate that fragmented world of all the devices that we have to target.

2. Exploring Universal React

Short description:

Universal React is cross-platform and follows the principle of learn once, write once, and run anywhere. It levels the playing field for small teams and indie developers. BlueSky is an example of a small team taking on big competitors using universal React. It starts with a single code base and provides truly native experiences for each platform. This approach allows web developers to use familiar technologies without learning new ones and saves costs by targeting multiple platforms with one code base.

So the first question on everyone's minds must be, what is universal React? So universal React are cross-platform React and React Native apps. In my opinion, what it means is a principle of learn once, write once, and run anywhere. And that's my answer. But a month ago at React Native London, Mo asked a panel of us that question. So I want to throw it back to you, Mo. What does it mean to you? Because to me, it's learn once, write once, run anywhere. But what about you?

I'm going to take a slightly different facet to this because I want to talk about what this gives us the potential to have. I think the power of universal apps is that it levels the playing field for small teams and indie developers to really take on the existing big behemoths that are there in the industry. A prime example of this is BlueSky. How many of you have heard of BlueSky recently? Exactly, right? So BlueSky is a small team of four or five developers who are taking on X, Twitter, whatever it's called these days, and they're taking on some of the richest people in the world to build their own social media, which I think is incredibly powerful. And really, the backbone of this is universal React, which is really cool. And so at its core, it starts with a single code base. You use one code base to target multiple platforms, be it web, mobile, TV, AR, VR. Really, the world is your oyster. And it uses React and the web principles that we're all familiar with and puts those into native technologies. But it does it in a way where it doesn't compromise the nativeness of each of those platforms. So these aren't some sort of shitty web view apps that you're used to that don't really feel like a native app. They're truly native experiences for each of the platforms that you're targeting. And what this means in principle is that you, as probably a group of mainly web developers, can use that familiar web technology, JavaScript, CSS styling, my favorite storybook, for app development, TV development, VR development, without picking up new technologies and languages. And the added benefit of this is it helps you target that complex fragmentation of the device landscape. You don't need a team per platform or per device. And this helps you save costs in rebuilding the same thing multiple times, which means more money for feature development, for improving the actual product, and really for keeping your PMs happy.

So, Mo, you said you developed apps since you were 13. Was that 10, 20, 30 years ago? Why don't you give us a bit of a history lesson? Look, I know I'm losing my hair and everything, but you don't have to make me feel like a grandpa hair. I thought you should color it. All right. Okay. That's my stuff. Unfortunately, the color doesn't apply to bald, but here we are. So history lesson.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Scaling Up with Remix and Micro Frontends
Remix Conf Europe 2022Remix Conf Europe 2022
23 min
Scaling Up with Remix and Micro Frontends
Top Content
This talk discusses the usage of Microfrontends in Remix and introduces the Tiny Frontend library. Kazoo, a used car buying platform, follows a domain-driven design approach and encountered issues with granular slicing. Tiny Frontend aims to solve the slicing problem and promotes type safety and compatibility of shared dependencies. The speaker demonstrates how Tiny Frontend works with server-side rendering and how Remix can consume and update components without redeploying the app. The talk also explores the usage of micro frontends and the future support for Webpack Module Federation in Remix.
Understanding React’s Fiber Architecture
React Advanced 2022React Advanced 2022
29 min
Understanding React’s Fiber Architecture
Top Content
This Talk explores React's internal jargon, specifically fiber, which is an internal unit of work for rendering and committing. Fibers facilitate efficient updates to elements and play a crucial role in the reconciliation process. The work loop, complete work, and commit phase are essential steps in the rendering process. Understanding React's internals can help with optimizing code and pull request reviews. React 18 introduces the work loop sync and async functions for concurrent features and prioritization. Fiber brings benefits like async rendering and the ability to discard work-in-progress trees, improving user experience.
Full Stack Components
Remix Conf Europe 2022Remix Conf Europe 2022
37 min
Full Stack Components
Top Content
RemixConf EU discussed full stack components and their benefits, such as marrying the backend and UI in the same file. The talk demonstrated the implementation of a combo box with search functionality using Remix and the Downshift library. It also highlighted the ease of creating resource routes in Remix and the importance of code organization and maintainability in full stack components. The speaker expressed gratitude towards the audience and discussed the future of Remix, including its acquisition by Shopify and the potential for collaboration with Hydrogen.
The Eternal Sunshine of the Zero Build Pipeline
React Finland 2021React Finland 2021
36 min
The Eternal Sunshine of the Zero Build Pipeline
For many years, we have migrated all our devtools to Node.js for the sake of simplicity: a common language (JS/TS), a large ecosystem (NPM), and a powerful engine. In the meantime, we moved a lot of computation tasks to the client-side thanks to PWA and JavaScript Hegemony.
So we made Webapps for years, developing with awesome reactive frameworks and bundling a lot of dependencies. We progressively moved from our simplicity to complex apps toolchains. We've become the new Java-like ecosystem. It sucks.
It's 2021, we've got a lot of new technologies to sustain our Users eXperience. It's time to have a break and rethink our tools rather than going faster and faster in the same direction. It's time to redesign the Developer eXperience. It's time for a bundle-free dev environment. It's time to embrace a new frontend building philosophy, still with our lovely JavaScript.
Introducing Snowpack, Vite, Astro, and other Bare Modules tools concepts!
Composition vs Configuration: How to Build Flexible, Resilient and Future-proof Components
React Summit 2022React Summit 2022
17 min
Composition vs Configuration: How to Build Flexible, Resilient and Future-proof Components
Top Content
Today's Talk discusses building flexible, resilient, and future-proof React components using composition and configuration approaches. The composition approach allows for flexibility without excessive conditional logic by using multiple components and passing props. The context API can be used for variant styling, allowing for appropriate styling and class specification. Adding variants and icons is made easy by consuming the variant context. The composition and configuration approaches can be combined for the best of both worlds.
Remix Architecture Patterns
Remix Conf Europe 2022Remix Conf Europe 2022
23 min
Remix Architecture Patterns
Top Content
This Talk introduces the Remix architecture patterns for web applications, with over 50% of participants using Remix professionally. The migration from single page applications to Remix involves step-by-step refactoring and offers flexibility in deployment options. Scalability can be achieved by distributing the database layer and implementing application caching. The backend for frontend pattern simplifies data fetching, and Remix provides real-time capabilities for collaborative features through WebSocket servers and Server-SendEvents.

Workshops on related topic

AI on Demand: Serverless AI
DevOps.js Conf 2024DevOps.js Conf 2024
163 min
AI on Demand: Serverless AI
Top Content
Featured WorkshopFree
Nathan Disidore
Nathan Disidore
In this workshop, we discuss the merits of serverless architecture and how it can be applied to the AI space. We'll explore options around building serverless RAG applications for a more lambda-esque approach to AI. Next, we'll get hands on and build a sample CRUD app that allows you to store information and query it using an LLM with Workers AI, Vectorize, D1, and Cloudflare Workers.
High-performance Next.js
React Summit 2022React Summit 2022
50 min
High-performance Next.js
Workshop
Michele Riva
Michele Riva
Next.js is a compelling framework that makes many tasks effortless by providing many out-of-the-box solutions. But as soon as our app needs to scale, it is essential to maintain high performance without compromising maintenance and server costs. In this workshop, we will see how to analyze Next.js performances, resources usage, how to scale it, and how to make the right decisions while writing the application architecture.