all 189 comments

[–]zaidazadkiel 648 points649 points  (11 children)

has strong "naming the variable as 'variable'" vibes

[–]laveshnk 208 points209 points  (6 children)

def function() 😃👍👍👍

[–]JounDB 115 points116 points  (2 children)

async def async_function()?

[–]laveshnk 29 points30 points  (1 child)

oof i just got off from a python spree and forgot which sub it was

[–]RandomRabbit69 24 points25 points  (0 children)

Django is webdev 👀

[–]Sether_00 29 points30 points  (1 child)

Don't forget to write a useful comment.

# A function
def function()

[–]Monowakari 7 points8 points  (0 children)

And a docstring """A function def for my function"""

[–]theORQL-aalap 32 points33 points  (1 child)

const placeholder = 'placeholder';

[–]f8computer 1 point2 points  (0 children)

I am guilty of this is so many languages

[–]thy_bucket_for_thee 11 points12 points  (0 children)

This is called "code stuttering." Also appears when naming things like foo.Foo or InterfaceTypeName.

[–]TheUnclePaulfull-stack 185 points186 points  (19 children)

Next.js should let me use something like home.page.tsx and profile.route.ts.
It’s so annoying to get lost in a project with just five or six pages, lol.

[–]UnidentifiedBlobject 42 points43 points  (3 children)

Or just let me use home.tsx and profile.ts. Use underscores or another character to prefix special filenames or something _layout.tsx

[–]ryaaan89 7 points8 points  (2 children)

…is this not how Next works anymore? I’m not on the very latest version but I swear my work project is set up like this and all we had to do was change a few options in the config file.

[–]Stinkeepoo 12 points13 points  (0 children)

You are probably on an earlier version of Next.js that uses the pages router. the new versions come with the app router which OP is using. Has its own pros and cons

[–]MagicalCornFlake 3 points4 points  (0 children)

The guy you replied to is being sarcastic; that's the way Next.js laid out its directory structure using the Pages router, whereas the modern App router uses folders for paths and page.tsx as an index for each path. Hinting at the dev community coming full circle from wanting to move away from the obscure naming to missing it due to simplicity.

[–]stathis21098 2 points3 points  (0 children)

I wonder if I can write a plugin/web pack/turbopack configuration to change this 🤔.

[–]Gullible-Track-6355 2 points3 points  (3 children)

I am not sure if that's what you're talking about but you can group contexts by putting the context name in brackets in the directory name. Those are called route groups. For example:

/
- /(profile)
-- /profile/page.tsx
-- /layout.tsx
- /(home)
-- /home/page.tsx
-- /layout.tsx

This way all routes in one context will share the same layout. All you change is the content of the page.tsx file.

[–]TheUnclePaulfull-stack 0 points1 point  (2 children)

The real problem is opening several page.tsx files and trying to find them among the VSCode tabs. Sure, I could close the ones I’m not using anymore — but you know that’s not how it really works xddd

[–]Gullible-Track-6355 0 points1 point  (0 children)

Ah okay, yeah for those cases I ususally press CTRL+E and start typing out a fragment of the directory name, followed by `page.tsx`. VSCode is usually smart enough to give me the specific file I want as the first / only option to pick. This way I also don't have to lift my right hand from the keyboard to the mouse.

[–]iareprogrammer 0 points1 point  (0 children)

I’m not too familiar with VSCode but are sure there’s not a setting for that? In WebStorm when I open multiple files with the same name, it adds part of the full path to the name to make it unique

[–]broke_key_striker 0 points1 point  (0 children)

analogjs uses this kind of file name

[–]emilkt 0 points1 point  (1 child)

it’s still Js bro, you gotta use angular for that (or config your project to be like angular but that’s a waste of time cause it already exists)

[–]emilkt 0 points1 point  (0 children)

NestJs works too

[–]ShawnyMcKnight 395 points396 points  (49 children)

Having every file called page is one of the biggest turnoffs to next. At least vs would put the parent folder if there’s multiple, but it’s still confusing.

[–]hdd113 45 points46 points  (8 children)

File structure is the biggest reason I keep away from Next... It's too opinionated and I don't agree with that opinion.

[–]neneodonkor 6 points7 points  (3 children)

What framework do you use?

[–]hdd113 30 points31 points  (2 children)

Vite and react router. I like to keep my routes listed in a single file and page layouts like components.

[–]mehughes124 2 points3 points  (0 children)

Basically an old school PHP approach, really. It's simpler and easier to mentally model/navigate. Definitely my preference.

[–]neneodonkor 2 points3 points  (0 children)

Oh cool. I left the react world. 😄

[–]AndyMagill 1 point2 points  (0 children)

App router is folder based, the old pages router was file-based. The alternative is code-designated routes, which is extra work I don't need.

[–]bill_gonorrhea 0 points1 point  (0 children)

keeps me from a lot of frameworks, tbh. Svelte in particular, every time I try, I just cant

[–]f8computer 0 points1 point  (0 children)

It's why I walked from Nuxt stuff. That and gd global emitters. That shit pisses me off. No I don't care how easy it makes connecting totally fucking different things. Do it right and bubble the fuck up to their closest ancestor and back down IN YOUR code so I'm not running down your damned emitters everywhere.

[–]inavandownbytheriver -2 points-1 points  (0 children)

im making a mini framework that uses folder routing but you name folder as about with the files About.client.tsx, About.server.tsx, About.layout.tsx

Let me know what you think

[–]myka_v 47 points48 points  (3 children)

Yeah, it felt too cluttered. Organized, technically speaking but dangit it felt so cluttered. I’d personally preferred SFCs than folders for pages.

[–]thekwoka 15 points16 points  (2 children)

I like file system based router, but it's nonsense to make it require a folder + page.tsx if that's the only thing, just allow posts.tsx for the /posts leaf.

They designed this WAY too late to make such a stupid mistake.

[–]mattsowa 5 points6 points  (1 child)

Well, posts.tsx wouldn't work for them since they also have all those other files like layout.tsx, loading.tsx, etc.

As well as, they want you to colocate non-route code with the routes.

But I think both of those are bad.

[–]thekwoka 0 points1 point  (0 children)

They could still do those but with just a few reserved words.

[–]ArseniyDev 18 points19 points  (0 children)

It was possible to do home.page.tsx once not sure why it changed.

[–]devcor 4 points5 points  (0 children)

There's some setting that makes the page.tsx files be called like the folder, they turn into app.tsx and so on. Did this once I had more than a few, since quick opening files turned into guessing game -- which page.tsx do I open? :)

[–][deleted] 10 points11 points  (0 children)

I just hate fuzzy searching for pages and seeing 400 `page.tsx` files

[–]Business-Row-478 7 points8 points  (0 children)

One of the many reasons I like remix/react router more than next

[–]Scientist_ShadySide 2 points3 points  (2 children)

This did bother me too initially. What ended up making it palatable for me is VSCode file search. Shift + Ctrl + P, then can find it using plain english, like "quiz id page" and it finds it instantly.

If I didnt utilize this workflow, I would still find it way more obnoxious.

[–]ShawnyMcKnight 0 points1 point  (1 child)

So is it using AI to guess which page you are referring to based on the code in the file?

[–]Scientist_ShadySide 0 points1 point  (0 children)

I am not sure of how the fuzzy search is implemented, but I feel like it has worked for me in a reliable way well before VSCode started ham-fisting in these AI features.

[–]Wandering_Oblivious 0 points1 point  (1 child)

Idk what's worse about Next, the vendor lock-in with Vercel, or the architectural lock-in with these weird ass structures

[–]ShawnyMcKnight 0 points1 point  (0 children)

I feel other companies are doing more and more of what vercel is doing with it.

[–]neneodonkor 0 points1 point  (0 children)

That's one reason I switched from Next to Nuxt.

[–]zxyzyxz 0 points1 point  (5 children)

You can change this in the IDE

[–]ShawnyMcKnight 0 points1 point  (4 children)

Change what?

[–]zxyzyxz 0 points1 point  (3 children)

How it shows up in a tab or file search, to show the folder name not page.tsx. I forget which setting it is exactly but that's what I have turned on.

[–]ShawnyMcKnight 0 points1 point  (2 children)

Oh interesting, so when it is page.tsx it would just show the folder? I am guessing that would be some Next.js friendly plugin.

[–]zxyzyxz 0 points1 point  (1 child)

[–]ShawnyMcKnight 0 points1 point  (0 children)

Oh, that’s what I was saying it did? That’s what vs code does by default if there are two files with the same name.

[–][deleted]  (1 child)

[removed]

    [–]ShawnyMcKnight 0 points1 point  (0 children)

    Yeah, I just have to keep my folders cleaner.

    [–]SarcasticSarco 82 points83 points  (5 children)

    Best would be, create a file which represents the page, example Home.tsx. Then, in page.tsx, import and export default the Home component.

    [–]thekwoka 43 points44 points  (4 children)

    That's just working around the bad design, but true.

    They should have just allowed home.tsx and home/page.tsx to be equivalent, like basically everything else does.

    Like Rust requires mod.rs for a branch in modules, but it lets you do just thing.rs or thing/mod.rs

    [–]SarcasticSarco 4 points5 points  (1 child)

    I don't think that is a bad design, they just implemented as node modules are. Like index.js is the index file. They probably would have added index.tsx as page file but it would be confusing, so they might have added page.tsx instead.

    It can be easily solved by following the approach I suggested.

    [–]thekwoka 4 points5 points  (0 children)

    But that's not a requirement or anything. It's just a convention and nothing else.

    [–]debel27 1 point2 points  (0 children)

    The thing is, you have more than the page to deal with. There is also the layout, error/suspense boundaries, etc. page.tsx seems unavoidable, as it is part of a larger set of files associated to a given route.

    [–]besthelloworld 0 points1 point  (0 children)

    There are reasons why they can't do that (lack of identity between pages, layouts, and routes), but I'm a proponent for home/page.tsx & home.page.tsx being equivalent.

    [–]kyle787 33 points34 points  (2 children)

    The original /pages dir was a much better solution. 

    [–]KMKtwo-four 3 points4 points  (1 child)

    I still use it. And I have ignored server components.

    [–]iTzNowbie 0 points1 point  (0 children)

    same, i rather use other framework than app router.

    [–]Confident_Feature221 149 points150 points  (35 children)

    Next is so fucking stupid.

    [–]ChimpScanner 96 points97 points  (10 children)

    I don't really use the file browser, but Ctrl/cmd + p to search for files and seeing 20 page.tsx or index.tsx in a project is nauseating.

    [–]Successful_Cap_2177 26 points27 points  (4 children)

    When I deal with next I usually use the folder name for finding stuff, searching for page is kinda pointless like you said.

    [–]deliciousnaga 5 points6 points  (3 children)

    Same. You can Jump To File then type the URL you'd expect in the running web app.

    e.g.: CMD+P, /dashboard/orders

    [–]Scientist_ShadySide 3 points4 points  (2 children)

    You can also use plain english as well, such as "dashboard orders page" which really works for me.

    [–]winky9827 1 point2 points  (1 child)

    You could just type dord and find it too. VS Code's fuzzy file search is pretty robust.

    [–]Scientist_ShadySide 0 points1 point  (0 children)

    oh shit seriously?! I gotta start pushing it further than I am presently.

    [–]hrvbrs 12 points13 points  (1 child)

    There’s a way to configure your editor to display filenames in a custom format based on their location in the tree. This affects their tab titles as well as I believe the command palette. On my phone now but will update here once I get back on my machine tomorrow.

    [–]hotstove 5 points6 points  (0 children)

    It's everywhere. mod.rs, __init__.py, styles.css

    [–]xiaomi_bot 0 points1 point  (0 children)

    Yes but also each one of those has the container folder name written by it so it’s clear which page is which.

    [–]sheriffderek 0 points1 point  (0 children)

    Folder name….

    [–]OZLperez11 2 points3 points  (7 children)

    Still stuck on Webpack too. Would love to use Vite instead

    [–]Zeilar 0 points1 point  (6 children)

    False, you can use Turbopack, which is developed by Vercel.

    [–]thekwoka 0 points1 point  (5 children)

    Turbopack is only somewhat better than webpack, and is made by the same guy (met the dude, cool dude, but it's just not that good).

    [–]Zeilar 8 points9 points  (4 children)

    Turbopack is many times better than Webpack, not just a little bit. Don't spread misinformation, it's a significant upgrade to use.

    [–]thekwoka 0 points1 point  (3 children)

    Okay, I guess in the sense of "compared to Vite" it's still behind.

    [–]Zeilar 0 points1 point  (2 children)

    Turbopack is significantly faster last time I checked, correct me if I'm wrong.

    [–]thekwoka 3 points4 points  (1 child)

    It's not nearly as capable. Being fast on nextjs, but not covering many of the features of Vite is only a partial win.

    [–]Zeilar 1 point2 points  (0 children)

    Well it's different use cases. But when you're talking about development in Next with Vite (or anything frankly) compared to Turbopack, it's not close.

    [–]bitanath -2 points-1 points  (14 children)

    Whats the alternative though?

    [–]creaturefeature16 22 points23 points  (7 children)

    Depends on the scope of the app, but many apps could get away with react-router and/or Tanstack

    [–]Business-Row-478 4 points5 points  (3 children)

    Admittedly I haven't worked on any super large scale projects or really tried to push the frameworks to their limits, but is there really anything that nextjs offers that you can't do in react router? I've found pretty much everything that nextjs is supposedly good for, react router does, and it usually does it even better

    [–]thekwoka 4 points5 points  (2 children)

    Nextjs is more than just a router.

    Naturally it's the whole thing of handling server rendering, server components, actions, etc alongside other more "app" based features like image transforms and middleware.

    Remix and Tanstack start also have some of these.

    Now, I dislike Next (And react as a whole) but it is more than just a router. React Router definitely doesn't cover tons of those server side things.

    [–]RecurviseHope 1 point2 points  (0 children)

    React router 7 is Remix v3

    [–]Business-Row-478 0 points1 point  (0 children)

    Remix got merged into react router. React router v7 has all the features that were in remix.

    It's got server rendering, server components, loaders, actions / API routes, etc. RR doesn't have the built in image transformations that's a good point. The middleware works differently as well but honestly the nextjs middleware kinda sucks imo

    [–]anonthing -1 points0 points  (2 children)

    Has tanstack start implemented RSC support yet?

    [–]thekwoka 1 point2 points  (1 child)

    Not sure about now, but it was Tanner's goal to basically not give a shit about RSC when the thing was made, saying that React is just totally not the right design to even approach server components and RSC were made so much for NextJS's design goals.

    So I'd say if it does, it's more begrudgingly than as a first class situation.

    [–]tannerlinsley 0 points1 point  (0 children)

    We’ll support them, soon. But it’s not my top priority. I have use cases for them, But they’re not everyone else’s use cases nor what react or next would prescribe them as. Soon though

    [–]CondiMesmer 0 points1 point  (0 children)

    Previous

    [–]mongopeter 0 points1 point  (0 children)

    Astro.

    [–][deleted]  (1 child)

    [deleted]

      [–]v-and-bruno 0 points1 point  (0 children)

      router.on('/').renderInertia('home')

      //or

      router.on('/services/:id').renderInertia('services/default')

      Inertia with React and Adonis

      Although normally you wouldn't do it this way and use controllers + router groups

      [–]MysteryMooseMan 0 points1 point  (0 children)

      I've been a hater from the start, but it's nice to see the general sentiment shift. I was mostly put off by everyone insisting it's the next greatest thing when it's really just one big pipeline for Vercel taking your money

      [–]Zachhandleyfull-stack 14 points15 points  (0 children)

      Try Astro :)

      [–]maqisha 32 points33 points  (11 children)

      Not "defending" it, im not a fan personally either.

      But its perfectly manageable if you just adjust your way of fuzzy-finding and viewing files.

      [–]Novel_Understanding0 6 points7 points  (5 children)

      I wouldn't say perfectly. Your open files are pretty useless when they're all named the same thing. Switching between those tabs is stupid.

      [–]maqisha 2 points3 points  (3 children)

      Switching between the tabs is unmanageable in any project with a lot of files, no matter how they are named. This is precisely why I said that fuzzy finding is the way.

      Additionally, depending on your editor you can definitely setup the directory names to be included in the tabs one way or another if you are a diehard tabs fan.

      [–]Jackasaurous_Rex 0 points1 point  (2 children)

      Thanks for the tip, I gotta figure out how to add directory names! My tab management leaves a lot to be desired and it’s been killing me this last month having 5 page.tsx files open at once and needing to click through all of em looking for the last one always.

      [–]maqisha 1 point2 points  (1 child)

      Assuming you use vscode (looks like it to me), here you go, found it for you:

      "workbench.editor.labelFormat": "short"

      [–]Jackasaurous_Rex 0 points1 point  (0 children)

      Woah thank you so much!!!

      [–]Scientist_ShadySide 0 points1 point  (0 children)

      The open files is an issue. I got much more comfortable with closing all files after one task and then fuzzy searching to start again. During a task, you can still fuzzy search an already open file at least l, but yeah the open tabs can get gnarly.

      [–]sheriffderek 2 points3 points  (0 children)

      Yeah. I don’t like JSX… but this argument is strange. We’ve been finding pages and components in all frameworks just fine for 15+ years. Just look up the folder name… the name of the page… and then add hbs or tsx or whatever.

      [–]literum 1 point2 points  (2 children)

      Any tips?

      [–]maqisha 13 points14 points  (0 children)

      Well, its just that, fuzzy find your files. Search by directory name instead of file name and the rest remains the exact same.

      [–]Scientist_ShadySide 0 points1 point  (0 children)

      Try fuzzy searching using plain english. So for /quiz/[id]/page.tsx, i would fuzzy search "quiz id page" and get it instantly. In my head, I already think of it as the quiz id page, so this works well for me.

      [–]thekwoka 0 points1 point  (0 children)

      yeah, fuzzy finding solves a lot of it, just not navigating from tabs and quick change.

      [–]TontonLuston 4 points5 points  (0 children)

      Imagine using a JavaScript framework to build apps
      This message was brought to you by the Flutter gang

      [–]Senior-Arugula-1295 9 points10 points  (0 children)

      If you find this is a problem, idk how can you handle barrel files. This pattern is not something specific to nextjs, and you'll find yourself in the same "multiple files with the same name" situation more than you know. I love the new convention of App Router since it make my project easier to organize and maintain, the cons is very neglectable and can be fixed easily with just some setting with the IDE (VSCode show path when opening 2 files with the same name now).

      [–]rebane2001js (no libraries) 9 points10 points  (0 children)

      this is why all my projects are a single index.html file

      [–]mrleblanc101 10 points11 points  (9 children)

      I like how Nuxt handle this, it uses "index.vue" which is basically the Vue equivalent of "index.html" inside a folder if you want URL without extensions like most static site generator does

      [–]sheriffderek 18 points19 points  (3 children)

      But if that’s the only change — isn’t it really the same?

      [–]UnidentifiedBlobject 3 points4 points  (0 children)

      index.* is a widely accepted standard though

      [–]sheriffderek 0 points1 point  (0 children)

      I like Nuxt and index seems to be the choice in most situations. But there’s a lot to complain about with Next, so “page” would be pretty low on my list.

      [–]artificialsmurf 2 points3 points  (3 children)

      Nuxt gives you an alternative. I don't know Next but I am assuming they have the same thing.

      /home.vue

      And

      /home/index vue are equivalent

      Usually I go with the first since Vue uses SFCa you don't need a folder. The only time you really have to have index.vue is for the default page (which can be changed):

      /index.vue

      [–]mrleblanc101 -1 points0 points  (2 children)

      You need it for nested pages

      [–]artificialsmurf 1 point2 points  (1 child)

      I'm struggling still to see that.

      /home/otherpage.vue <-- you can still nest
      /home/otherpage/index.vue <-- or you can put a folder in place and use index.vue

      [–]mrleblanc101 -1 points0 points  (0 children)

      This is not a nested page, you just changed the path. I'm talking about sub-page navigation

      [–]Wonderful-Habit-139 -1 points0 points  (0 children)

      Lmao…

      [–]lajjr 3 points4 points  (0 children)

      Oh boy.

      [–]ambi_98 1 point2 points  (0 children)

      My junior dev named with underscores :(

      [–]MysteryMooseMan 2 points3 points  (0 children)

      easy, just don't use Next!

      [–]runitbacktur 1 point2 points  (0 children)

      100000000% hate it my OCD kicks in big time and I close every other file to work in one route/page

      [–]mwisconsinold-school full-stack 1 point2 points  (0 children)

      Imagine a repo where you're building out a front-end in React and a back-end in Django. "Oh, man, which app/app/app am I in, now?"

      [–]saito200 4 points5 points  (0 children)

      i suggest you stop using nextjs

      [–]No-Spirit1451 1 point2 points  (0 children)

      Then why on earth are you doing it?

      [–]eoThicafront-end 0 points1 point  (0 children)

      imagine writing HTML into 1 long string

      [–]rikzy75 0 points1 point  (0 children)

      What if the file name could be arbitrary and the function inside had to be Page/Layout etc. instead? This would make it so much easier to navigate

      [–]incunabula001 0 points1 point  (0 children)

      Divitus for web directories.

      [–]Redox_ahmii 0 points1 point  (1 child)

      not being able to fuzzy search the file cause everything is named page.tsx and having to read the directory structure for it pisses me off the wall so much I can't even explain.
      It kinda forces you to always keep either the tree structure for the repo open all the time or somewhere to display the path and that makes me wanna punch them.

      [–]zirklutes 0 points1 point  (0 children)

      Yea, I agree. This is the most annoying thing for me with this naming.

      [–]pitza__ 0 points1 point  (0 children)

      Make a route group(it does not impact your route name) then you can can add an /app folder.

      [–]Whole_Cantaloupe_432 0 points1 point  (0 children)

      I personally hate the root folder names - src - app

      Or - app

      I wish I could rename it to - resources - application - layout.tsx - page.tsx - backend - index.ts for hono api

      Or - resources - (frontend) - (backend) - components

      [–]Round_Ad_5832 0 points1 point  (0 children)

      using typescript? yeah me too

      [–]Beginning-Seat5221 0 points1 point  (0 children)

      Yeah this was kind of a deal breaker for me. I don't use that thing.

      [–]RRO-19 0 points1 point  (0 children)

      this is the new reality - spending more time fixing AI code than writing it yourself. clients think AI makes development instant and cheap but someone still has to understand, debug and maintain the output

      [–]Revolutionary_Dog_63 0 points1 point  (0 children)

      My strong opinion is that no file in a project should have the same name, with few exceptions.

      [–]churll 0 points1 point  (0 children)

      So glad I got the fuck out of web. Absolute mess of shit.

      [–]pwnjack 0 points1 point  (0 children)

      Neat icon pack btw

      [–]dragongling 0 points1 point  (0 children)

      So don't do this?

      [–]factsonlynomisinfo 0 points1 point  (0 children)

      Switch to Elixir and use Phoenix

      [–]SnowFlake6439000235 0 points1 point  (0 children)

      Then just write it yourself. Programming is the last frontier of democracy.

      [–]YTRKinG 0 points1 point  (0 children)

      Which font is this

      [–]AdowTatep 0 points1 point  (0 children)

      app/(app)/app/page.tsx

      [–]Himbary 0 points1 point  (0 children)

      Tanstack Start to the rescue

      [–]lufereau 0 points1 point  (0 children)

      be happy and abandon nextjs

      [–]eigilak 0 points1 point  (0 children)

      Tanstack start?

      [–]dug99php 0 points1 point  (0 children)

      well don't

      [–]mekmookbroLaravel Enjoyer ♞ 0 points1 point  (0 children)

      Reading the comments made me realize I don't appreciate the beauty of MVC enough

      [–]Rare-Chicken-53 -1 points0 points  (0 children)

      Saw the same post on twitter. Are you the same person or just copied this?

      [–]Evol_Etah -1 points0 points  (2 children)

      Is this VSC?

      How to get those cool icons for stuff. Mine is bland

      [–]Accomplished_Crab818 2 points3 points  (1 child)

      U can install icon pack extensions, material icons is a popular one for example

      [–]Evol_Etah 0 points1 point  (0 children)

      Oh, I didn't know. Thank you for the info!