Support to set <html lang /> from metadata? #49415
Replies: 8 comments 7 replies
-
I would also like to add my support for this feature, and I would also like to request other export async function generateMetadata() {
return {
htmlAttributes: {
lang: "ar-AE",
dir: "rtl",
},
title: "Ahoj",
}
} Here's a summary of the currently available options/workaround we have, to demonstrate why I think we need framework-level support for this. Pattern 1. -
|
Beta Was this translation helpful? Give feedback.
-
Pattern 2. -
|
Beta Was this translation helpful? Give feedback.
-
I think layouts do refresh (via RSC) when their parameters change. The difference is keeping internal state of the component by remounting the component with changing Problem is supporting default I like idea of the dedicated api |
Beta Was this translation helpful? Give feedback.
-
This is a demo what I think could be achieved without middleware. https://middleware-cache-three.vercel.app |
Beta Was this translation helpful? Give feedback.
-
Also looking for a solution for this. As far as I can see, there's now no way to set the lang attribute serverside AND keep a certain component mounted while navigating between locales (e.g. have the |
Beta Was this translation helpful? Give feedback.
-
I have this same issue and find it insane that nextjs doesn't have an answer for this 🤔 |
Beta Was this translation helpful? Give feedback.
-
Same issue here. I need change html attr in children layout component |
Beta Was this translation helpful? Give feedback.
-
It is crazy that there is still not a possible workaround for such an essential issue. |
Beta Was this translation helpful? Give feedback.
-
As far as I know you can only set
<html lang={lang} />
in root layout. It can be dynamic from[lang]
route, which is problematic when you want to have a default locale.In my opinion
lang
should be configurable same as other metadata as layout cannot always know before route loads data.This should result in something like
Do you plan tu support this? Or maybe is there a workaround similar to
useServerInsertedHTML
.I would like to avoid unnecessary usage of
middleware.ts
.Beta Was this translation helpful? Give feedback.
All reactions