Why using pages instead of a js file that has routes? #23443
Replies: 2 comments 1 reply
-
I 100% agree with this. I've always thought Nextjs needs an option to specify router declaration similar to react-router. There are a few solutions though which may help. 1. Use custom page extensionsThis lets you put files other than pages inside the 2. Write your page components in other files, then import and export them inside the
|
Beta Was this translation helpful? Give feedback.
-
Nowadays, you can use Since I am not sure I follow your last point, you do know you can Finally, and this is an opinion piece so feel free to ignore it, but it looks like you are coming in with a "this is what works for me" attitude, and framing how you build an application from that angle, instead of learning how the frameworks does things. I am not bashing, nor saying that you shouldn't criticize and judge the framework decisions, so here's an attempt at addressing your list.
This is a subjective appreciation, right? What's non-weird naming. It's only for dynamic routes that the
To what you have come across up to this point, web development is as vast as the ocean
This is actually an area where I would agree
There's tons of tests backing up this feature
The default export from any file inside
Why would you? other than to test it perhaps?
What's do you mean here? TypeScript with Next.js is as easy as creating
Already touched on this using |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The main reason I stayed away from next.js for so long (I've been used gatsby for years) was the pages folder.
Look this file name
[slug].js
... just look at that file name. I never seen anything like that and I'm not even sure how my filesystem will handle it...I see these issues
import Post from './[post].js
.. looks weird..I'd suggest something much more clearer
In this way everything is much more flexible, less magic.
All tutorials I see so far are using this convention of
pages
and I think is really putting me off. I'm sure there is a way to use programmatically, but is so little used that makes me worry using it because I might go into issues and nobody knows how to fix them.Beta Was this translation helpful? Give feedback.
All reactions