Next.js Discord

Discord Forum

How do I keep a root layout for not-found.tsx while setting the <html lang={}> attribute correctly?

Answered
yolocat posted this in #help-forum
Open in Discord
I'm following the app directory i18n example (https://github.com/vercel/next.js/tree/canary/examples/app-dir-i18n-routing) and while adding multi-tenancy support. My app dir structure is as follows:
app:
  [tenant]:
    [lang]:
      layout.tsx - <html lang={params.lang}>
      ...
  admin:
    layout.tsx - <html lang={"en"}>
    ...

I need the <html> tag in [tenant]/[lang]/layout.tsx to set the lang attribute correctly, so I can't put the admin/layout.tsx at the root (which would presumably make two <html> tags when accessing [tenant]/[lang]/...) . This works all good when the routes are found. When they aren't, a not-found.tsx is rendered with the root layout. How do I let not-found.tsx have a layout while making sure that the lang attribute is set correctly?
Answered by yolocat
[...404]/page.tsx did the trick :)
View full answer

1 Reply

[...404]/page.tsx did the trick :)
Answer