DEV Community


Discussion on: How to handle Next.js Api routes more type safely

hassnainabass profile image
Hassnain Abass

This is good,
But don't you think you have made very simple thing into a very complicated one?

ryohlan profile image
Ryohlan Author

Next.js NextApiHandler can define only one response body type.
So if a route has multiple methods and response body types, you will use the Type Assertion and you will need to write many codes more.
This utility method can decrease codes a little.