Next.js Discord

Discord Forum

Parallel Routes are weird to understand

Answered
Ninhache posted this in #help-forum
Open in Discord
Avatar
Hi !

I try to use parallel routes for the first time and It's a pain a bit !

Here's a part of my directories in a tree-like format :

[id]
├── @items
│   ├── layout.tsx
│   └── page.tsx
├── @nav
│   ├── enchant
│   │   └── page.tsx
│   ├── items
│   │   └── page.tsx
│   │
│   └── spells
│   │   └── page.tsx
│   ├── layout.tsx
│   └── page.tsx
├── layout.tsx
└── page.tsx



Main problems are the following :
And I cannot figure how to solve my problems, I cannot understand why is it failing

-> visiting /[id]/ returns correct things but the right menu isnt correct to me, i need something to visit, the only that comes to my head is to add a redirect in the /[id]/@nav/page.tsx that will redirect to /[id]/items
-> so, visiting thanks to the redirect (on /[id]/items), Im getting 404, maybe due to the missing /[id]/@items/items/page.tsx, so, I created it, but still the same..
-> visiting /[id]/items without the redirect is the same tho
Answered by Ninhache
i just basically copy/paste the [parallel-route's code](https://github.com/vercel/next-app-router-playground/tree/main/app/parallel-routes) from vercel

and it's working.. here's my new files :

├── @nav
│   ├── enchant
│   │   └── page.tsx
│   └── spells
│       └── page.tsx
│   ├── default.tsx
│   ├── layout.tsx
│   └── page.tsx
├── default.tsx
├── not-found.tsx
├── layout.tsx
└── page.tsx

I removed @items, it wasnt usefull and, since I always need it, I place the page's code in the [id]/page.tsx instead
View full answer

10 Replies

Avatar
try adding a default.tsx inside [id] to avoid the 404's

export default function Default() {
return null
}
Avatar
Didnt solve it
Still a 404 :/
Avatar
what url gives u 404?
Avatar
with the redirect
/builder/[id]/ "auto" route to /builder/[id]/items that gives 404
Avatar
that redirect isnt a good idea maybe
Avatar
i just basically copy/paste the [parallel-route's code](https://github.com/vercel/next-app-router-playground/tree/main/app/parallel-routes) from vercel

and it's working.. here's my new files :

├── @nav
│   ├── enchant
│   │   └── page.tsx
│   └── spells
│       └── page.tsx
│   ├── default.tsx
│   ├── layout.tsx
│   └── page.tsx
├── default.tsx
├── not-found.tsx
├── layout.tsx
└── page.tsx

I removed @items, it wasnt usefull and, since I always need it, I place the page's code in the [id]/page.tsx instead
Answer
Avatar
so its not parallel anymore? why not just (nav) instead of @nav
Avatar
I maybe didnt well understand when to use parallele :/
I needed something to change only a part of my app
in my case, that was about a specific component