DEV Community

Cover image for React 19 is now stable ! What’s New 👇
Random
Random

Posted on • Originally published at Medium

React 19 is now stable ! What’s New 👇

React 19 has arrived with exciting new features and improvements!

Hello Dev’s its me Md Taqui Imam, The React 19 is now stable so let’s explore what’s new and how you can use these features in your projects.

This guide will walk you through the most important updates with practical examples.

Follow me in Github⭐


Actions and Form Handling ⭐

Actions are one of the biggest additions in React 19. They make it easier to handle form submissions and data mutations.

function UpdateProfile() {
 const [error, submitAction, isPending] = useActionState(
 async (previousState, formData) => {
 const name = formData.get("name");
 try {
 await updateProfile(name);
 return null; // No error
 } catch (err) {
 return "Failed to update profile";
 }
 },
 null
 );
return (
 <form action={submitAction}>
 <input type="text" name="name" />
 <button type="submit" disabled={isPending}>
 {isPending ? "Updating…" : "Update Profile"}
 </button>
 {error && <p className="error">{error}</p>}
 </form>
 );
}
Enter fullscreen mode Exit fullscreen mode

Using Form Status 🟢

The new useFormStatus hook makes it easy to show loading states:

import { useFormStatus } from 'react-dom';
function SubmitButton() {
 const { pending } = useFormStatus();

 return (
 <button disabled={pending}>
 {pending ? 'Submitting…' : 'Submit'}
 </button>
 );
}
Enter fullscreen mode Exit fullscreen mode

New Hooks 🎉

1. useOptimistic 🆕
This hook helps create instant feedback while waiting for server responses:

import { use } from 'react';
function UserProfile({ userPromise }) {
 const user = use(userPromise);

 return (
 <div>
 <h1>{user.name}</h1>
 <p>{user.email}</p>
 </div>
 );
}
Enter fullscreen mode Exit fullscreen mode

Save it


Document Metadata Support

React 19 now supports metadata tags natively:

function BlogPost({ post }) {
 return (
 <article>
 <title>{post.title}</title>
 <meta name="description" content={post.summary} />
 <link rel="canonical" href={post.url} />

 <h1>{post.title}</h1>
 <p>{post.content}</p>
 </article>
 );
}
Enter fullscreen mode Exit fullscreen mode

Asset Loading Improvements

New APIs for optimizing resource loading:

import { preload, preinit, preconnect } from 'react-dom';
function App() {
 // Preload important resources
 preload('/fonts/main.woff2', { as: 'font' });
 preinit('/styles/critical.css', { as: 'style' });
 preconnect('https://api.example.com');
return <Main />;
}

Enter fullscreen mode Exit fullscreen mode

Web Components Support

React 19 now fully supports custom elements:

function App() {
 return (
 <div>
 <custom-element
 stringProp="hello"
 numberProp={42}
 objectProp={{ foo: 'bar' }}
 onCustomEvent={(e) => console.log(e.detail)}
 />
 </div>
 );
}
Enter fullscreen mode Exit fullscreen mode

Other Improvements 🛠️

Ref as a Prop

// Old way with forwardRef
const OldInput = forwardRef((props, ref) => (
 <input ref={ref} {props} />
));
// New way in React 19
function NewInput({ ref, props }) {
 return <input ref={ref} {props} />;
}
Enter fullscreen mode Exit fullscreen mode

Better Error Reporting 🔥

React 19 provides clearer error messages and better hydration error reporting:

const root = createRoot(container, {
 onCaughtError: (error) => {
 // Handle errors caught by Error Boundaries
 logError(error);
 },
 onUncaughtError: (error) => {
 // Handle errors not caught by Error Boundaries
 reportFatalError(error);
 }
});
Enter fullscreen mode Exit fullscreen mode

Conclusion / That’s it 😅

React 19 brings many exciting features that make development easier and more efficient. The new form handling capabilities, hooks, and improved asset loading will help developers build better applications with less code.

Remember that while these features are now stable, it’s recommended to test thoroughly when upgrading existing applications to React 19.

For more information, check out the official React 19 announcement and documentation.

And see you in next blog post, till then Byy, Have a Nice Day.

Happy coding!


github

twitter

portfolio

buymeacoffee

Top comments (18)

Collapse
 
monty_65 profile image
Monty

Thanks Dude for the update 🙏

Collapse
 
john90 profile image
John bobby

👍

Collapse
 
random_ti profile image
Random

You'r welcome 🙌

Collapse
 
barsie profile image
Sirineo Barila

I didn't have time to digest react 18 and the 19 version is already out. Too #FastTech?

Collapse
 
random_ti profile image
Random

Tech moves at lightning speed these days

Collapse
 
barsie profile image
Sirineo Barila

Agreed with that!
By the way I reviewed your GitHub profile and it there is this fun link to one of your project that allow to see how valuation of a developer? I think is pretty good, thought you might want to add social sharing capabilities (linkedin, Reddit...) and an error is thrown when trying to download the image after valuation saying that user have reached the daily download quota.

Collapse
 
bradwestfall profile image
Brad Westfall

React 18 came out over 2.5 years ago

Collapse
 
barsie profile image
Sirineo Barila

That's completely true @bradwestfall, but my procrastination doesn't do me any favours.

Collapse
 
devluc profile image
Devluc

It's great to see you back at writing Taqui

Collapse
 
random_ti profile image
Random

Thank you so much sir ! It feels great to be back at it

Collapse
 
sakrad_cmmi_111f1a88c5c47 profile image
Sakrad CMMI

Thanks for updating.

Collapse
 
random_ti profile image
Random

You'r welcome, i hope you find helpfull 🙌🙌

Collapse
 
vemareddy_shrishveshredd profile image
VEMAREDDY SHRISHVESH REDDY 22115161

Nice

Collapse
 
random_ti profile image
Random

Thanks 🙌

Collapse
 
solomen profile image
Solomon Ogwu

Thanks

Collapse
 
random_ti profile image
Random

🙌🙌🙌

Collapse
 
abdullah_nadir profile image
Abdullah Nadir

👍

Collapse
 
random_ti profile image
Random

🙌