Skip to content

params are always accessed with promise in app-dir#87

Merged
aralroca merged 3 commits intoaralroca:mainfrom
timotew:patch-1
Jul 12, 2025
Merged

params are always accessed with promise in app-dir#87
aralroca merged 3 commits intoaralroca:mainfrom
timotew:patch-1

Conversation

@timotew
Copy link
Copy Markdown
Contributor

@timotew timotew commented Jul 9, 2025

This check doesn't work as expected and cause a issues with next-js 14. i.e

Error: Route "/[lang]" used `params.lang`. `params` should be awaited before using its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis
export default async function __Next_Translate_new__197f0ebfc2e__(props) {
 const detectedLang = await props.params?.lang ?? props.searchParams?.lang
                                       ^

 if (detectedLang === 'favicon.ico') return <RootLayout {...props} />

What is the purpose of this pull request? (put an "X" next to item)

[ ] Documentation update
[x ] Bug fix
[ ] New feature
[ ] Other, please explain:

What changes did you make? (Give an overview)
Always access param using promise
Which issue (if any) does this pull request address?

Is there anything you'd like reviewers to focus on?

This check doesn't work as expected and cause a issues with next-js 14.
i.e
```
export default async function __Next_Translate_new__197f0ebfc2e__(props) {
 const detectedLang = await props.params?.lang ?? props.searchParams?.lang
                                       ^

 if (detectedLang === 'favicon.ico') return <RootLayout {...props} />
```
@timotew timotew changed the title param is always accessed with promise in app-dir params are always accessed with promise in app-dir Jul 9, 2025
Copy link
Copy Markdown
Owner

@aralroca aralroca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

@aralroca
Copy link
Copy Markdown
Owner

@timotew can you run yarn test? It looks like some tests are failing; we probably need to adapt them.Thanks

@timotew
Copy link
Copy Markdown
Contributor Author

timotew commented Jul 12, 2025

Fixed now, thanks for the reminder.

@aralroca aralroca merged commit 671bec5 into aralroca:main Jul 12, 2025
6 checks passed
@timotew timotew deleted the patch-1 branch July 12, 2025 18:29
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