Defining a layout without adding the html or body tags
Answered
Eulophid wasp posted this in #help-forum
Eulophid waspOP
I've seen many demos with people writing layouts without the html or body tags, how do I get this functionality?
Answered by Bigeye scad
You have to use
@Eulophid wasp
html and body tags only at the layout file which is at the root of your application , generally at /app/layout.tsx or /src/app/layout.tsx , with all the other layouts files which are going to be nested inside it . you don't need html or body tags .@Eulophid wasp
7 Replies
Bigeye scad
You have to use
@Eulophid wasp
html and body tags only at the layout file which is at the root of your application , generally at /app/layout.tsx or /src/app/layout.tsx , with all the other layouts files which are going to be nested inside it . you don't need html or body tags .@Eulophid wasp
Answer
@Bigeye scad You have to use `html` and `body` tags only at the `layout` file which is at the root of your application , generally at `/app/layout.tsx` or `/src/app/layout.tsx` , with all the other layouts files which are going to be nested inside it . you don't need `html` or `body` tags .
<@781053954346975253>
Eulophid waspOP
what about in this context where theyre using empty tags
@Eulophid wasp or this https://x.com/asidorenko_/status/1725548472839950553
Bigeye scad
in this he is working with
layout on /app/movies/layout.tsx@Eulophid wasp I've seen many demos with people writing layouts without the html or body tags, how do I get this functionality?
in the root layout, you we definitely have html and body tag but in nested route layout, we don't need to have html or body
Barbary Lion
I need this functionality for a project at work. Specifically, we're rendering through another HTTP server that will render out the full HTML document. We have an interface for introducing scripts/styles/meta tags to the <head> HTML tag, but we cannot render the <head> HTML tag ourselves.
I'd really like to use Next.js in this ecosystem, but I need to disable Next.js from insisting on rendering <html>, <head>, or <body> in the layout.
I'd really like to use Next.js in this ecosystem, but I need to disable Next.js from insisting on rendering <html>, <head>, or <body> in the layout.
@Eulophid wasp what about in this context where theyre using empty tags
This example is wrong. You must have <html> and <body> at the root of your page.