Skip to content

Commit 5dcc9b5

Browse files
committed
fix: migrate blog and help to async params (it's a Promise in Next.js 16)
Fixes: Error: Route "/blog/[id]" used `params.id`. `params` is a Promise and must be unwrapped with `await` or `React.use()` before accessing its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis
1 parent a6ceec6 commit 5dcc9b5

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

apps/frontend/src/app/(content)/(info)/blog/[id]/page.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ type BlogPageProps = {
1010
params: { id: string };
1111
};
1212

13-
export function generateMetadata({ params }: BlogPageProps): Metadata {
14-
const id = params.id;
13+
export async function generateMetadata({
14+
params,
15+
}: BlogPageProps): Promise<Metadata> {
16+
const id = (await params).id;
1517
const post = getPostData('blog', id);
1618

1719
const publicUrl = process.env.NEXT_PUBLIC_URL;
@@ -32,8 +34,8 @@ export function generateMetadata({ params }: BlogPageProps): Metadata {
3234
};
3335
}
3436

35-
const BlogPost = ({ params }: BlogPageProps) => {
36-
const { id } = params;
37+
const BlogPost = async ({ params }: BlogPageProps) => {
38+
const { id } = await params;
3739
let post: PostType;
3840

3941
try {

apps/frontend/src/app/(content)/(info)/help/[id]/page.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ type HelpPageProps = {
1010
params: { id: string };
1111
};
1212

13-
export function generateMetadata({ params }: HelpPageProps): Metadata {
14-
const id = params.id;
13+
export async function generateMetadata({
14+
params,
15+
}: HelpPageProps): Promise<Metadata> {
16+
const id = (await params).id;
1517
const post = getPostData('help', id);
1618

1719
const publicUrl = process.env.NEXT_PUBLIC_URL;

0 commit comments

Comments
 (0)