Routing Assistance
I am trying really hard to try and understand the Routing thing with NextJS and I just can't wrap my head around it. Right now, I'm just trying to scaffold out my site with generic stuff and get routing setup, but I just can't figure it out.
The site when loaded at
/
should be the same as if a person goes to /spells
(1st screenshot)
Right now, if I go to /spells
I see the 2nd screenshot. The content of /spells
should be loading where the cards are (which is currently in (main)/_components/content/content.tsx
. The same would go for if someone browses to /suggestedGear
and /maskedCarnivale
. The area with the cards replaced appropriately. The 3rd screenshot is my current directory structure (which is probably the problem).
What is not correct in this setup for me to get the experience I am looking for?24 Replies
but thats not app dir
hmm?
i'm not following at all.
ah because you had a pages folder
even if i move say, the spells folder outside directly under the app folder, the way it is rendered is the same
i thought
()
meant grouping and has no impact on routingim not sure about that XD
underscore has no impact on routing
my organization skills suck trying to keep things organized for this app
I ussualy use only the "/" layout.tsx, and inside the page.tsx of each folder I put the componentes that I need
then my
layout.tsx
needs to be redone
well, enterily XD because the layout.tsx receives the page.tsx as prop
so this is my "/" layout.tsx
so all pages will render the Topbar
so, for my case, i need to move the header and sidebar to the main layout to be shared across all views
yep
what would be inside the
page.tsx
?
because that is where i am calling the header and all that jazzdepends? the one directly under "App"? its "/"
for spells page, it will be> App/spells/page.tsx
is the root page.tsx empty or what?
ok, i think things are starting to click
What i was sayin is that most ppl want to use a topbar, so it will be in the top layout.
in /dashboard or others, you might only need the page and thats it,
but if you have a submenu then you can use a second layout xD
yas! things are clicking
leave it to me to make things overly complex
enjoy 😄
Solution
App dir is fun, until you make things overly complex 😛