amannn / next-intl

šŸŒ Internationalization (i18n) for Next.js
https://next-intl-docs.vercel.app
MIT License
2.56k stars 237 forks source link

Prepare for `ppr` and `dynamicIO` #1493

Open amannn opened 1 week ago

amannn commented 1 week ago

Next.js is changing the rendering behavior. It's still very early, and things are moving, but it would be interesting to see if we can adapt next-intl to better suit the needs of these rendering modes.

For now, this issue is meant to collect related resources.

Related

zipme commented 6 days ago

Hi @amannn, thank you for the great work on next-intl!

Just to confirm, does next-intl currently not support ~per-page revalidation~ partial prerendering (PPR) for Next 15? Since params are now asynchronous, it seems we need to do something like this:

export default async function Layout(
  props: { params: Promise<{locale: string}> }
) {
  const params = await props.params;
  setRequestLocale(params.locale);

Would this approach opt out of static rendering?

amannn commented 6 days ago

Hmm, are we talking about the same thing? PPR in Next.js refers to partial prerendering, but based on your comment I think you mean the same thing?

I haven't had the time to experiment with PPR yet, but am planning to do this in the next few days. I'd be curious if generateStaticParams has an effect on whether reading params requires dynamic renderingā€”at least from a user perspective I'd expect it to render fine statically. Not sure if other pieces are relevant though like 'use cache';.

I'll update this thread here with my findings!

zipme commented 6 days ago

Thanks for the update! Yes, I was referring to partial prerendering (I updated my comment). I would have expected generateStaticParams to influence this behavior, and it indeed worked in Next 14. However, after upgrading to 15, it no longer functions as expected.

It's still unclear whether params qualifies as a dynamic API. It's not listed here: https://nextjs.org/docs/app/building-your-application/rendering/server-components#dynamic-apis, but in the version 15 upgrade guide, it does mention an async request dynamic API change, and params appears in the list.

amannn commented 6 days ago

That's interesting, yes. There seems to be a new API coming for accessing top-level params: https://github.com/amannn/next-intl/issues/663#issuecomment-2449100558. Maybe that one will have a different behavior when used with PPR.