Next.js Discord

Discord Forum

RootLayout and RouteLayout setup problems

Answered
Tomistoma posted this in #help-forum
Open in Discord
TomistomaOP
I am tryign to create custom layout for the (auth) pages.
when i open the main website everything is fine,
after moving to the new layout page when i try to go back either with Link or with browser back button i get -
NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.

folder structure -
└── 📁app
    └── 📁(auth)
        └── 📁signuplogin
            └── layout.js
            └── page.js
    └── favicon.ico
    └── globals.css
    └── layout.js
    └── page.js






thank you.
Answered by B33fb0n3
you have two root layouts (from auth and from app). But the auth layout is wrapped with the app layout. Either removes the wrapping by creating another route group for the app or remove the second html & body tag inside the auth. Like that the error should go away
View full answer

5 Replies

Answer
@Tomistoma I already tried that without the html and body tags, When i do that the error is gone. but the AuthLayout is not applied. And the RootLayout does.
yea, then do this:
Either removes the wrapping by creating another route group for the app or remove the second html & body tag inside the auth.
TomistomaOP
nesting the (app) inside a folder worked, thank you very much -
new folder structure -
└── 📁app
    └── 📁(app)
        └── 📁contact
            └── page.js
        └── 📁counseling
            └── page.js
        └── 📁programs
            └── page.js
        └── 📁registration
            └── page.js
        └── favicon.ico
        └── globals.css
        └── layout.js
        └── page.js
    └── 📁(auth)
        └── 📁signuplogin
            └── layout.js
            └── page.js
    └── 📁api
        └── 📁campuses
            └── route.js
        └── 📁contactUs
            └── route.js
        └── 📁courses
            └── route.js
        └── 📁instructors
            └── route.js
        └── 📁students
            └── route.js
    └── 📁lib
        └── 📁validation
            └── campus.js
            └── contactUsSchema.js
            └── course.js
            └── instructor.js
            └── student.js
        └── db.js
happy to help