I'm encountering a TypeScript error in my Next.js 15.1.3 app with a dynamic route [slug]/page.tsx. The error occurs during build time when deploying to Vercel (works fine locally) and suggests that the params type is expected to be a Promise, but I'm providing a simple string type.
Here's the error I'm getting: Type error: Type 'PageProps' does not satisfy the constraint 'import("/vercel/path0/.next/types/app/(app)/nemovitost/[slug]/page").PageProps'. Types of property 'params' are incompatible. Type '{ slug: string; }' is missing the following properties from type 'Promise<any>': then, catch, finally, [Symbol.toStringTag]
My code:
// app/(app)/nemovitost/[slug]/page.tsx
import { Suspense } from 'react';
import { getPropertyBySlug } from '@/lib/actions';
import { notFound } from 'next/navigation';
import { Featured } from "@/components/featured";
// ... other imports
interface PageProps {
params: {
slug: string;
}
}
export default async function PropertyDetailPage({ params }: PageProps) {
const property = await getPropertyBySlug(params.slug);
if (!property) {
notFound();
}
return (
<>
<div className='font-geist-sans flex justify-center'>
<div className="flex-col w-[1100px] mx-4">
<h1 className="text-blue-800 font-bold">
{property.title}
</h1>
{/* Rest of the JSX */}
<Suspense fallback={<LoadingFeatured />}>
<Featured />
</Suspense>
</div>
</div>
</>
);
}
I've tried various approaches including:
Using different type definitions for the params Restructuring the component Adding 'use server' directive Splitting the code into multiple components Creating separate API routes