From 987703c5e7a4014522c009dff228855caa33bcbf Mon Sep 17 00:00:00 2001 From: Haitao Pan Date: Tue, 11 Nov 2025 13:43:26 +0800 Subject: [PATCH] fix: handle async searchParams in blog pagination MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Issue: Next.js 15 requires searchParams to be awaited as it's now a Promise. **Error Message:** "Route "/blog" used `searchParams.page`. `searchParams` is a Promise and must be unwrapped with `await`" ### Solution: Updated `src/app/blog/page.tsx` to properly await searchParams before accessing its properties. **Changes:** - **BlogPage component** - Added `await searchParams` before accessing page property - Used destructuring: `const { page } = await searchParams` - Updated parseInt to use destructured `page` variable ### Result: - Fixed runtime error when accessing pagination params - Pagination now works correctly with async searchParams - Blog list pages load successfully with `/blog?page=X` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- dashboard/src/app/blog/page.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dashboard/src/app/blog/page.tsx b/dashboard/src/app/blog/page.tsx index 75f0813..e375a9d 100644 --- a/dashboard/src/app/blog/page.tsx +++ b/dashboard/src/app/blog/page.tsx @@ -34,8 +34,9 @@ type PageProps = { export default async function BlogPage({ searchParams }: PageProps) { const posts = await getHomepagePosts() + const { page } = await searchParams const postsPerPage = 10 - const currentPage = parseInt(searchParams.page || '1', 10) + const currentPage = parseInt(page || '1', 10) const totalPages = Math.ceil(posts.length / postsPerPage) if (currentPage < 1 || currentPage > totalPages) {