Live data from Hacker News

Next.js Layouts RFC: Nested routes and layouts, designed for Server Components

nextjs.org

21–30 of 123 posts

Re: Next.js Layouts RFC: Nested routes and layouts, designed for Server Components

#21
post #2

Lee from Vercel, happy to answer questions about the RFC or future plans for Next.js. This RFC has been years in the making – and I'm pretty happy with where we've landed.

>happy to answer questions about the RFC Would love to hear about the parts of the RFC where you guys took some inspiration from Remix!

https://twitter.com/sebmarkbage/status/1528858510754459648

Re: Next.js Layouts RFC: Nested routes and layouts, designed for Server Components

#22

I'm excited to see the wheels turning, but it feels a bit like the best feature of Next.js IMHO (SSG) is going to get more difficult, or possibly become unusable. A deprecation feels incoming. It could be confirmation bias as I've been a little worried about that for awhile since people using SSG aren't as likely to buy cloud services, so there's some incentive misalignment there, but ever since the Image component w…

Naw, I don't agree. SSG is a killer feature. The fact that Next.js is able to do both SSG and SSR means that it's positioned to be a wholesale replacement for most React tech stacks. You can still have a "CSR-like" app with SSG, while having all of the Next.js conventions (such routing, layouts, etc.). Additionally, it's actually pretty useful for sites that need to be heavily SEO-optimized. Next.js is an impressive framework.

Re: Next.js Layouts RFC: Nested routes and layouts, designed for Server Components

#23
post #22

I'm excited to see the wheels turning, but it feels a bit like the best feature of Next.js IMHO (SSG) is going to get more difficult, or possibly become unusable. A deprecation feels incoming. It could be confirmation bias as I've been a little worried about that for awhile since people using SSG aren't as likely to buy cloud services, so there's some incentive misalignment there, but ever since the Image component w…

Naw, I don't agree. SSG is a killer feature. The fact that Next.js is able to do both SSG and SSR means that it's positioned to be a wholesale replacement for most React tech stacks. You can still have a "CSR-like" app with SSG, while having all of the Next.js conventions (such routing, layouts, etc.). Additionally, it's actually pretty useful for sites that need to be heavily SEO-optimized. Next.js is an impressive…

Static isn't going anywhere. In my opinion, one the best parts about Next.js is you can blend static with dynamic, on a per-page basis. Your landing page can be completely static + periodically updated in the background (i.e. ISR) and your /dashboard page could be a fully server-rendered application behind auth. You can do both without ejecting from the framework and being able to update and receive performance/security improvements. We've called Next.js a "hybrid framework" because of this, but I don't have a great name for it.

Re: Next.js Layouts RFC: Nested routes and layouts, designed for Server Components

#24
post #11
post #2

Lee from Vercel, happy to answer questions about the RFC or future plans for Next.js. This RFC has been years in the making – and I'm pretty happy with where we've landed.

Am I correct thinking this will help create a simpler integration with - just hypothetically - Prisma calls that are dependent on app auth states in a single page? Replacing auth providers and moving them into Layouts? Daily user, very excited!

Yes, I believe you are correct. This would be a good example to add as the updates to `next/router ` start to materialize.

Re: Next.js Layouts RFC: Nested routes and layouts, designed for Server Components

#25
What amazing news! Nextjs is fun to use, but the pages concept has felt a little clunky. Nuxtjs (vue's version) has a great pages abstraction, but it doesn't nest layouts, like this proposal.

There's some obvious inspiration from other frameworks, as Remix and Angular 2.x have had nested routing for years.

Hopefully this will allow for less repetition in pages and a more elegant structure to projects.

Re: Next.js Layouts RFC: Nested routes and layouts, designed for Server Components

#26
post #14

Could a smart person please compare and contrast this RFC and the ideas of remix.run?

According to Ryan Florence (Remix's creator) they are "ripping features straight from Remix". https://twitter.com/ryanflorence/status/1528859776930545665

I definitely understand the reaction. This is an existential threat to Remix.

However, this is why I don't use Twitter. Remix is not just "an open-source project", it's a full-fledged company. This is definitely not the time (or the forum) to lay your cards out on the table...

Re: Next.js Layouts RFC: Nested routes and layouts, designed for Server Components

#27
post #2

Lee from Vercel, happy to answer questions about the RFC or future plans for Next.js. This RFC has been years in the making – and I'm pretty happy with where we've landed.

I like that you have thought about incremental adoption. However it looks like you're effectively deprecating the "/pages" directory. Which kind of sucks, as it's much more informative name, than the new generic "/app" folder.

Also, does this mean you cannot have a page named "layout" anymore?

Lastly, I appreciate all the hard work that goes into nextjs, it's a great developer experience and my goto framework.

Re: Next.js Layouts RFC: Nested routes and layouts, designed for Server Components

#28
post #14

Earlier quoted context omitted.

According to Ryan Florence (Remix's creator) they are "ripping features straight from Remix". https://twitter.com/ryanflorence/status/1528859776930545665

So we need to give credit now to every little bit of inspiration we get when coming up with new features and ideas? Not really sure what the problem is here.

You'd have to ask Ryan :)

IMO it's really just a matter of time before good ideas end up in other projects. It's inevitable. Obviously everyone wants their framework to be as good and popular as possible.

Re: Next.js Layouts RFC: Nested routes and layouts, designed for Server Components

#29
post #27
post #2

Lee from Vercel, happy to answer questions about the RFC or future plans for Next.js. This RFC has been years in the making – and I'm pretty happy with where we've landed.

I like that you have thought about incremental adoption. However it looks like you're effectively deprecating the "/pages" directory. Which kind of sucks, as it's much more informative name, than the new generic "/app" folder. Also, does this mean you cannot have a page named "layout" anymore? Lastly, I appreciate all the hard work that goes into nextjs, it's a great developer experience and my goto framework.

Part of the thinking behind `app/` is that each section of your application can become its own app. Separate layouts, separate data fetching, and more. `pages/` was mapped very linearly to routes – `pages/index.js` was the index route. But with `app/`, that is not the case.

That's a good point about having a route `/layout` – I will check with the team about that.

Re: Next.js Layouts RFC: Nested routes and layouts, designed for Server Components

#30
post #2

Lee from Vercel, happy to answer questions about the RFC or future plans for Next.js. This RFC has been years in the making – and I'm pretty happy with where we've landed.

Not seeing it in the article, but how are you handling `index` routing in the `app` folder? If you are putting it in the top directory (e.g. `/app/index.js`), is it not able to get a custom `layout.js` file (as that position is used for the global variant)? If it's in an `index` folder (e.g. `/app/index/page.js`), how would one create a route for `example.com/index`?

The current working idea is that you wouldn't use index.js. There are Layout Components and Page Components, both explicitly defined by `layout.js` and `page.js`. We are open to other opinions here, though. Others have shared similar sentiment: https://github.com/vercel/next.js/discussions/37136
Post reply on HN