The Complete Developer Guide to React 19, Part 3: Upgraded Support

Authors
Hristo Totov
Software Engineer
@
Callstack

Previously, document metadata tags like <title>, <link> or <meta> would need to be inserted manually in an effect the <head> element, or by third-party libraries like react-helmet. However, React 19 introduces a native support for rendering metadata tags directly into components:

function BlogPost({post}) {
return (
<article>
<h1>{post.title}</h1>
<title>{post.title}</title>
<meta name="author" content="Josh" />
<link rel="author" href="https://twitter.com/joshcstory/" />
<meta name="keywords" content={post.keywords} />
<p>
Eee equals em-see-squared...
</p>
</article>
);
}

When the BlogPost component is rendered, it will detect the metadata tags and automatically hoist them up to the <head> section of the document. This will allow developers to create React applications with much better SEO.

An important note here is that this feature is for simpler use cases, and to create even more powerful SEO a combined usage with third-party libraries such as react-helmet is recommended.

Support for stylesheets

Historically React did not pay much attention to styles and was more or less overlooking them and leaving it to developers to figure out how to approach them. However, in React 19 the meta team decided they care a bit more now. Developers can now choose a precedence for each stylesheet and not have to rely on the DOM style precedence rules. This change would simplify the handling of stylesheets, especially in the scenarios for server-side and concurrent rendering.

function ComponentOne() {
return (
<Suspense fallback="loading...">
<link rel="stylesheet" href="foo" precedence="default" />
<link rel="stylesheet" href="bar" precedence="high" />
<article class="foo-class bar-class">
{...}
</article>
</Suspense>
)
}
function ComponentTwo() {
return (
<div>
<p>{...}</p>
<link rel="stylesheet" href="baz" precedence="default" /> <-- will be inserted between foo & bar
</div>
)
}
view raw Stylesheets.jsx hosted with ❤ by GitHub

The stylesheet with href=”baz” in ComponentTwo, although having the same precedence as the stylesheet with href=”foo" in ComponentOne will be inserted after it as it’s higher on the component tree. Moreover, the <Suspense> will ensure the stylesheets are loaded first before showing the content, preventing unstyled content flashing.

Another interesting fact is that if a component with a stylesheet is rendered multiple times React will only include the stylesheet once in the document:

function App() {
return <>
<ComponentOne />
...
<ComponentOne /> // won't lead to a duplicate stylesheet link in the DOM
</>
}

Support for Async Scripts

React 19 enhances support for async scripts by enabling their rendering anywhere within the component tree. It ensures that these scripts are deduplicated and loaded only once, regardless of being rendered by multiple components. This improvement simplifies the integration of async scripts into React applications, eliminating the need to manage their relocation or duplication.

Async scripts like <script async="" src="..."> load in arbitrary document order and the react team has introduced better support for them by allowing developers to render them anywhere in component three without having to manage to relocate and to deduplicate script instances.

The usage is simple:

function MyComponent() {
return (
<div>
<script async={true} src="..." />
Hello World
</div>
)
}

Support for preloading resources

New APIs to optimize page performance during initial loads and updates by facilitating the loading and preloading of browser resources are introduced in React 19. These APIs enable developers to prefetch DNS requests, establish connections to servers, and preload fonts, stylesheets, and scripts, enhancing resource-loading efficiency and improving the user experience.

Informing the browser about resources it will likely need to load as early as possible during the initial document load and client-side updates can significantly enhance page performance.

An example of usage can be as follows:

import { prefetchDNS, preconnect, preload, preinit } from 'react-dom'
function MyComponent() {
preinit('https://.../path/to/some/script.js', {as: 'script' }) // loads and executes this script eagerly
preload('https://.../path/to/font.woff', { as: 'font' }) // preloads this font
preload('https://.../path/to/stylesheet.css', { as: 'style' }) // preloads this stylesheet
prefetchDNS('https://...') // when you may not actually request anything from this host
preconnect('https://...') // when you will request something but aren't sure what
}

The above JavaScript would result in the following DOM/HTML:

<html>
<head>
<link rel="prefetch-dns" href="https://...">
<link rel="preconnect" href="https://...">
<link rel="preload" as="font" href="https://.../path/to/font.woff">
<link rel="preload" as="style" href="https://.../path/to/stylesheet.css">
<script async="" src="https://.../path/to/some/script.js"></script>
</head>
<body>
...
</body>
</html>

As you can see links and scripts are prioritized by their utility to early loading, not call order. Moreover, these APIs can be used to optimize initial page loads by moving the discovery of additional resources like fonts out of stylesheet loading and making client updates faster by prefetching a list of resources used by anticipated navigation for example.

Support for custom elements 

In past versions, using Custom Elements in React has been difficult because React treated unrecognized props as attributes rather than properties.

React 19 now offers complete support for custom elements, successfully passing all tests on Custom Elements Everywhere. This update addresses previous issues by correctly handling unrecognized props during both server-side and client-side rendering. 

Conclusion

React 19 introduces a host of new features and improvements aimed at simplifying and enhancing the development experience for React developers. These updates cater to various aspects of application development, from handling asynchronous operations and improving form management to providing robust support for server-side rendering and optimizing resource loading.

By addressing pain points and introducing innovative solutions, React 19 aims to make the development process more intuitive, efficient, and scalable. These enhancements collectively contribute to building faster, more responsive, and user-friendly applications, reinforcing React's position as a leading framework for modern web development.

Read the other parts of the guide

Why not get back to the previous parts? Read all about Async Handling in the first part, and new enhancements in the second one:

Insights

Learn more about React

cover

Jun 24Article

Writing Custom Renderers for React

Learn how React renderers work, why RNTL needed a new test renderer, and what it takes to connect React Reconciler to a host environment.

cover

Dec 18Live Stream

Building iOS Live Activities With React: Inside Voltra

Learn how to build iOS Live Activities and Dynamic Island experiences using pure JSX, no Swift or native code required.

cover

Nov 27Podcast

From React Native Web to React Strict DOM

Nicolas Gallagher (Meta) explains how React Strict DOM evolved from React Native Web, providing a shared syntax that compiles to native or web with zero overhead.

cover

Nov 21Podcast

React Foundation: New Governance Model for React and React Native

Seth Webster, Executive Director of the React Foundation, details its new governance model, Meta's role, and how partners like Callstack and Microsoft will ensure stability and scale.

cover

Apr 9Podcast

Exploring TanStack Ecosystem: From React Query to TanStack Start

Tanner Linsley breaks down TanStack’s evolution-from React Query to Start, and why client-first React apps still matter in today’s full-stack landscape.

Event Cover

Feb 20Live Stream

Create React App is Out: Exploring Alternatives & Community Proposals

CRA is now deprecated, so we explore other options for starting web React projects, going through Vite, TanStack Router, Parcel, and Rsbuild to check the developer experience.

Event Cover

Feb 13Live Stream

State of React 2024 Breakdown

Let's take a deep dive into the long-awaited State of React survey from 2024; brace yourselves for a two-hour ride.

cover

Sep 3Article

The Complete Developer Guide to React 19, Part 2: New Enhancements

Discover React 19's key updates, including improved `ref` usage, error reporting, and context consumption in part 2 of this practical developer guide.

cover

Sep 2Article

The Complete Developer Guide to React 19, Part 1: Async Handling

Explore the key features of React 19 beta, focusing on new hooks that enhance async handling, state management, and form submissions.

cover

May 2Article

Understanding React Server Components

React Server Components (RSC) are still work in progress, but now it's the best time to explore these core concepts of future React. Find out why and how!

cover

Mar 19Tutorial

The Hard Way vs. The React Native AI SDK Way: Stop Writing Custom Modules for Every Model

Learn how React Native AI uses a unified provider model to switch between cloud and on-device LLMs without rewriting application logic, enabling reliable AI experiences online and offline.

cover

Mar 12Tutorial

Build Smarter Apps: Tool Calling & AI Orchestration Explained

Learn how on-device models in React Native can call tools, interact with external APIs, and return structured outputs you can use directly in application logic.

cover

Mar 5Tutorial

MLC LLM + React Native: On-Device AI Without the Pain

Learn how to run third-party on-device LLMs in React Native using MLC LLM. Choose your models, run them efficiently across platforms, and keep a unified JavaScript API with React Native AI.

cover

Feb 24Tutorial

Intelligent Fallbacks with Apple Intelligence in React Native

Learn how to use Apple’s built-in Foundation Models in React Native apps, reduce memory usage, and enable fast, fully on-device AI with React Native AI Apple.

cover

Feb 10Tutorial

What Is the React Native AI SDK? A Complete Intro & Quickstart

Learn why on-device AI matters for React Native apps, how local LLMs behave offline, and what problems React Native AI is designed to solve from day one.

cover

Jan 29Tutorial

Implementing an Android TurboModule with Kotlin

Learn how to implement a React Native TurboModule on Android, from the TypeScript spec and Codegen to the Kotlin implementation and package registration.

cover

Jan 19Tutorial

Working with Different Threads in Swift TurboModules

Learn how JavaScript, native module, background, and main threads interact in React Native TurboModules, and how to use GCD queues to run async work safely in Swift.

cover

Jan 9Tutorial

How to Add Type-Safe Constants to Swift TurboModules

Learn how to expose typed, immutable constants from a Swift TurboModule using Codegen, and get full end-to-end type safety between native and JavaScript.

cover

Dec 30Tutorial

Adding Event Emitters to Your TurboModule in Swift

Learn how to emit native events from a Swift TurboModule and subscribe to them in JavaScript, including proper memory management and Codegen integration.

cover

Dec 22Tutorial

Writing Your First TurboModule in Swift

Learn how to build a fully working TurboModule in Swift, integrate it with Codegen, and bridge it through Objective‑C inside an Expo app.