Next.js Discord

Discord Forum

notFound() is not allowed to use in root layout

Unanswered
Shar Pei posted this in #help-forum
Open in Discord
Shar PeiOP
Hi, i have this structure...
app
  - dashboard
    - [organization]
      - layout.tsx <- notFound throw an error
      - page.tsx
    - layout.tsx <- notFound working as expected
    - page.tsx


I wanna check in my layout if my organization is existing, otherwise i wanna throw a 404 (notFound)...
The problem is that when i use notFound in this layout, this error is shown:

Error: notFound() is not allowed to use in root layout

It is not the root layout :/

When i use it in the upper layout file in dashboard it is working great.
I don't get it!
Do you have an idea ?

Thank you in advance.

3 Replies

Shar PeiOP
up
@Shar Pei up
did you tried updating your Next.js package?
how did you use notFound() in app/dashboard/[organization]/layout.tsx?