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
yolocatOP
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:
I need the
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?1 Reply
yolocatOP
[...404]/page.tsx
did the trick :)Answer