aralroca / next-translate-plugin

Next-translate plugin for i18n in Next.js 🌍 - Load page translations and use them in an easy way!
MIT License
31 stars 18 forks source link

Usage with next 15 - `params` should be awaited before using its properties #85

Open Vahor opened 1 week ago

Vahor commented 1 week ago

What version of this package are you using? 2.6.2

What happened?

In NextJS 15: https://nextjs.org/blog/next-15#async-request-apis-breaking-change params should be awaited.

and currently that's not the case: https://github.com/aralroca/next-translate-plugin/blob/99c1faefcd7167a7caa309f2affc7d0d807a76e4/src/templateAppDir.ts#L102

What did you expect to happen?

params should be awaited. https://nextjs.org/docs/app/building-your-application/upgrading/version-15#params--searchparams example:

-    const detectedLang = props.params?.lang ?? props.searchParams?.lang
+   const params = await props.params;
+   const searchParams = await props.searchParams;
+   const detectedLang = params?.lang ?? searchParams?.lang

Note: This might not be the only issue with next 15 as applying this patch does no fix all my issues.

Are you willing to submit a pull request to fix this bug? yes

aralroca commented 1 week ago

Feel free to PR 👌😊