News for hackers. Stuff that matters.
Re:Next.js Layouts RFC: Nested routes and layouts, designed ... by leerob on Monday May 23, 2022 @05:46PM (#31485176)
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.
Re:Next.js Layouts RFC: Nested routes and layouts, designed ... by gitgud on Monday May 23, 2022 @07:20PM (#31486076)
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 ... by leerob on Monday May 23, 2022 @07:37PM (#31486196)
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 ... by migueloller on Monday May 23, 2022 @08:37PM (#31486641)
Since segments are determined by folders, you should be able to do `/layout/page.js` for a `/layout` route.
Re:Next.js Layouts RFC: Nested routes and layouts, designed ... by codefined on Monday May 23, 2022 @06:25PM (#31485605)
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`?

Re:Next.js Layouts RFC: Nested routes and layouts, designed ... by leerob on Monday May 23, 2022 @07:38PM (#31486207)
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
Re:Next.js Layouts RFC: Nested routes and layouts, designed ... by realce on Monday May 23, 2022 @06:33PM (#31485678)
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!

Re:Next.js Layouts RFC: Nested routes and layouts, designed ... by leerob on Monday May 23, 2022 @07:11PM (#31486000)
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 ... by saeedjabbar on Monday May 23, 2022 @06:03PM (#31485363)
Excited to try this out in my next project :)
Re:Next.js Layouts RFC: Nested routes and layouts, designed ... by leerob on Monday May 23, 2022 @06:06PM (#31485393)
Open to any feedback you have – we've already started work on the implementation, and will adjust as necessary based on the RFC discussion.
Re:Next.js Layouts RFC: Nested routes and layouts, designed ... by rs_rs_rs_rs_rs on Monday May 23, 2022 @06:34PM (#31485694)
>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!

Re:Next.js Layouts RFC: Nested routes and layouts, designed ... by leerob on Monday May 23, 2022 @06:59PM (#31485892)