Skip to content

refactor(Next.js/client-side-rendering): remove Suspense reveal throttling saving about 300ms FCP. - #929

Closed
MaxwellCohen wants to merge 1 commit into
e18e:mainfrom
MaxwellCohen:feat/next-faster-client-rendering
Closed

MaxwellCohen wants to merge 1 commit into
e18e:mainfrom
MaxwellCohen:feat/next-faster-client-rendering

Conversation

@MaxwellCohen

@MaxwellCohen MaxwellCohen commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

This PR moves to the useEffect approach for client-only components in Next.js, removing the 300ms delay caused by suspense. First paint / FCP goes from about 354.4 ms to 82.8ms.

I used LLMs to help review and test this code. If this PR isn't helpful or isn't wanted, please close it.

Checklist

  • If updating UI/UX components ensure you have added screenshots or a gif or video of the changes to the PR description
  • If this is a dependabot PR that bumps a metaframework version, ensure that all package versions in the package match the versions installed by the metaframework version being bumped
  • If this is a dependabot PR that bumps a metaframework version in a starter-* package, ensure that the deps, and file content matches the output of the metaframeworks recommended starter/default project

@MaxwellCohen MaxwellCohen changed the title refactor(client-side-rendering): remove Suspense reveal throttling about 300ms FCP. refactor(Next.js/client-side-rendering): remove Suspense reveal throttling about 300ms FCP. Nov 23, 2026
@MaxwellCohen MaxwellCohen changed the title refactor(Next.js/client-side-rendering): remove Suspense reveal throttling about 300ms FCP. refactor(Next.js/client-side-rendering): remove Suspense reveal throttling saving about 300ms FCP. Nov 23, 2026
@AlexanderKaran

Copy link
Copy Markdown
Collaborator

Hi @MaxwellCohen

Thanks for the PR. I have some questions about this change.

So, when setting this up, we followed examples from the docs here: https://nextjs.org/docs/app/guides/single-page-applications#what-is-a-single-page-application

My understanding is that Next.js can still prerender a component marked with 'use client', so we used the following pattern to render it only in the browser:

const ClientSideRenderedDetail = dynamic(
  () => import('./ClientSideRenderedDetail'),
  { ssr: false },
)

Which is in the docs example here: https://nextjs.org/docs/app/guides/single-page-applications#rendering-components-only-in-the-browser

Right through the examples in the link above, there is also suspense used as well.

Now using useEffect I can only find a linked example here: https://nextjs.org/docs/messages/react-hydration-error#solution-1-using-useeffect-to-run-on-the-client-only

However, I could have missed something, so please let me know if I have.

Our main focus when setting these up is to do the following in this order:

1: Follow a frameworks guides/setups/docs and use their main pattern
2: When tests are very unfair make changes to compare apples to apples

Its a fine line and not always achived but anyway let me know your thoughts here.

Initialy I am thinking I would be happy with this change if NextJS docs recomend this as the set up for client only routes but maybe it already does and I missed it.

@MaxwellCohen

Copy link
Copy Markdown
Contributor Author

Hi @AlexanderKaran

I am basically doing the same thing as in the useEffect example you linked: https://nextjs.org/docs/messages/react-hydration-error#solution-1-using-useeffect-to-run-on-the-client-only

What I think you are missing is React and Next.js's design choice around suspense throttling: "should be just large enough to prevent jank when lots of different parts of the UI load in rapid succession, but not large enough to make the UI feel sluggish.". Adding an artificial ~300ms delay before showing CSR content; this delay doesn't really impact real-world apps. Some argue that it makes apps feel smoother by reducing popcorning. But it makes Next.js look much worse in benchmarks. I don't think this is well documented/understood.
This change would go under the following exception:

2: When tests are very unfair make changes to compare apples to apples

I agree this is a fine line, and I don't know what the right answer is.
If I were in your shoes, this would be a flip-of-a-coin question with no clear right or wrong answer. Another possible approach is to add a note that Next.js/React suspense throttling can result in an additional 300ms FCP delay. As I said in my PR description, "If this PR isn't helpful or isn't wanted, please close it."

A response to this PR closing it because the docs say to use Next.js's dynamic component, as explained: https://nextjs.org/docs/app/guides/single-page-applications#rendering-components-only-in-the-browser would be just as reasonable as merging it.

@AlexanderKaran

AlexanderKaran commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

@MaxwellCohen Got some updates from the NextJS team and am going to be merging their change here: #963 due to update to their docs vercel/next.js#102401

Any questions let me know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants