Next.js Discord

Discord Forum

has an invalid "GET" export: Type "{ params: { slug: string; }; }" is not a valid type for the fun

Answered
American black bear posted this in #help-forum
Open in Discord
American black bearOP
During the production build process (next build), the TypeScript compiler consistently raises a type error in the file located at app/api/blog/[slug]/route.ts. The error message is as follows:

Type error: Route "app/api/blog/[slug]/route.ts" has an invalid "GET" export:
  Type "{ params: { slug: string; }; }" is not a valid type for the function's second argument.


This error indicates a fundamental mismatch between the function signature of the exported GET handler and the type definition expected by the Next.js framework for dynamic API routes.
Answered by Giant panda
Make it { params: Promise<{ slug: string; }>; }
View full answer

1 Reply

Giant panda
Make it { params: Promise<{ slug: string; }>; }
Answer