Skip to content
Dashboard

Improving INP with React 18 and Suspense

VP of Developer Experience

How to optimize your application's responsiveness.

Link to headingInteraction to Next Paint (INP)

An INP below or at 200 milliseconds means that your page has good responsiveness.An INP below or at 200 milliseconds means that your page has good responsiveness.
An INP below or at 200 milliseconds means that your page has good responsiveness.

Link to headingHow does INP differ from FID?

Link to headingReact 18 and Selective Hydration

// JavaScript for the entire page must be loaded
// before the page can become interactive
export default function HomePage() {
return (
<>
<Header />
<Body />
<Footer />
</>
);
}

JavaScript for the entire page must be loaded before the page can become interactive.

import { Suspense } from 'react';
// Using a loading component as the Suspense fallback
function Loading() { ... }
// Using `Suspense` makes hydration non-blocking
export default function HomePage() {
return (
<>
<Header />
<Suspense fallback={<Loading />}>
<Body />
<Footer />
</Suspense>
</>
);
}

Using Suspense makes hydration non-blocking with React 18.

Link to headingCase Study: Next.js Site

// Simplified version of the changes made to
// the nextjs.org landing page to improve INP with `Suspense`
export default function Index() {
return (
<Page title="Next.js by Vercel - The React Framework">
<SkipNavContent />
<Banner badge="New" href="/blog/next-12-2">
{"Next.js 12.2 →"}
</Banner>
<Hero />
<Suspense fallback={<Loading />}>
<Features />
<Customers />
<Learn />
<Newsletter />
<Footer />
</Suspense>
</Page>
);
}

Simplified version of the changes made to the nextjs.org landing page to improve INP with Suspense.

You can omit the Suspense fallback, but proceed with caution. If any components in the subtree suspend, you risk showing a broken, empty state.

Interaction to Next Paint (INP) of nextjs.org from Vercel Analytics.Interaction to Next Paint (INP) of nextjs.org from Vercel Analytics.
Interaction to Next Paint (INP) of nextjs.org from Vercel Analytics.

Link to headingOther ways to optimize INP