Next.js Discord

Discord Forum

`embed` tag causing odd behavior

Answered
Bridled Titmouse posted this in #help-forum
Open in Discord
Bridled TitmouseOP
I am using nextjs 14.2.3 with app router. I have a route segment of /reports/[id]/page.tsx. and when i try to use the html tag in this page to render a pdf like this

<embed type="application/pdf" src="sample.pdf" width="640" height="480" />

The route renders the entire app again inside this page, including the root layout and my route layout, and it doesn't embed the pdf ... ¯\_(ツ)_/¯.

if I remove the <embed> tag and use something else - it rendered correctly.

basically, the app just doesn't work when I use the <embed> tag - does anyone know why or experience it?
Answered by joulev
does it work if you use this?
 <embed
  type="application/pdf"
  src="/sample.pdf"
  width="640"
  height="480"
/>

where the src is an absolute path
View full answer

3 Replies