Next.js Discord

Discord Forum

Create a subdirectory under /app that still gets rendered on the root URL. Is that possible?

Answered
Laysan Albatross posted this in #help-forum
Open in Discord
Avatar
Laysan AlbatrossOP
├── home
│ └── page.tsx
by default, this page can be accessed with rooturl/home
but it would be great if it's possible to keep the file where it is but render it directly with rooturl
Answered by joulev & fuma pray for Schneider
Route groups. With the ( )
View full answer

11 Replies

Avatar
joulev & fuma pray for Schneider
Use route groups like app/(group1)/(group2)/page.tsx then it’ll still be in /
Avatar
Laysan AlbatrossOP
you mean app/directory1/directory2/page.tsx? Because that would lead to the content being available on baseurl/directory1/directory2/page.tsx, doesn't it?
Or only when the directory contains a page.tsx? Is that the key difference?
Avatar
joulev & fuma pray for Schneider
Route groups. With the ( )
Answer
Avatar
joulev & fuma pray for Schneider
Read the route group docs for more information
Avatar
Laysan AlbatrossOP
so name the directory with ()
yesss thank you so much.
:galactic_brain:
Avatar
Laysan AlbatrossOP
So I know should have the possibility to render page.tsx on the rooturl, but use a completely independent layout file for it. At least that's what I hope.
Image
Avatar
Laysan AlbatrossOP
okay no. ^^ no matter where I put it, it's still a child of the RootLayout. (obviously)
fck it, I'll find a way.