'Should we create as many number of files as there are number of apis in nextjs

In next js we have to create a seperate file for each new api like for /user there will be user.js with a seperate handler. And a seperate one for /user/goldmember. Will it not create too much files? Is there another way?



Solution 1:[1]

There's no other way to route pages in Nextjs. Websites are not built to handle large/excessive number of routes, because it's not really necessary. If you're worried about creating i.e. large number of user endpoints (/user/:id), that's where dynamic routes come into play.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 matspiewak