Open mleimer opened 1 year ago
Hi @mleimer, This concept is a bit tricky, but it is a powerful feature. I will try to explain this to you with this fork of your repo: https://github.com/hipdev/nextjs-slots-page
Now, as the documentation says, slots are not segments of the route and are loaded simultaneously or conditionally on one or more pages that share the same layout. It is a feature that allows you to do complex things.
In the repo that you share, you are only loading these slots for the layout that they share, but the pages are things independent of the content of the slots, and you are not defining those. This is where I think confusion can arise, and the documentation could be improved. That is why, when going to /members the page is not found.
The use cases for parallel routes are multiple, the documentation defines some cases, I really like using them to make intercepted routes and show the page that the user wants to see as a modal, if the user reloads the page, then it will be a default page.
You can play around with parallel routes using a default logic or showing a loading logic, is amazing. I left you a default state in my forked demo. Play around going to /dashboard and /members to see the difference.
I leave you a demo --> https://github.com/hipdev/rick-and-morty-characters
My personal site is also using these two advanced concepts for the blog, even if I don't have any posts yet hahaha 🥲.
I hope this help you to understand.
@hipdev Thank you very much for your explanations. I think I got your point. In this case, I would be in favor of rephrasing the sentence "The file path /@team/members would be accessible at /members." such that one does not accidentally believe that it becomes a page if not combined with intercepted routes.
I also don't understand this. From the docs, it seems I should be able to use parallel routes without intercepting.
So for example:
app
overview
@detail
detail
page.tsx
page.tsx
layout.tsx
Navigating to /overview/detail should render both overview as well as detail in the same layout.
Currently, it seems this feature only works for in-page navigation but not for initial URL loads. If this is the case, it should be renamed from "parallel routes" to "interim parallel routes" or something like that, and make clear in the docs that these routes are not accessible outside of in-page navigation.
Something is not right with Next.js 14.1 parallel route subfolders and global-error.js. I hope they can fix them soon.
Link to the code that reproduces this issue
https://github.com/mleimer/nextjs-slots-page
To Reproduce
npm run dev
ornpm run build
andnpm run start
Current vs. Expected behavior
Current A "404: This page could not be found" exception is thrown
Expected The page is rendered as described in https://nextjs.org/docs/app/building-your-application/routing/parallel-routes#convention
Although slots DO NOT affect the URL structure. I understand it this way, that as soon as add a sub-folder with a page to that slot, that it should be a public route again. Otherwise I misunderstand this quote.
Verify canary release
Provide environment information
Which area(s) are affected? (Select all that apply)
App Router, Routing (next/router, next/navigation, next/link)
Additional context
No response