August 18, 2026

Dropping an iframe into a React component takes one line. Doing it without damaging your Largest Contentful Paint and Cumulative Layout Shift takes slightly more thought, and this is the part most guides skip.
Everything here applies to Next.js App Router, Pages Router and plain React alike.
Wrap the iframe in a container with a fixed aspect ratio so the browser reserves the space before the frame loads. Without that you get a layout shift when it arrives, and CLS is the metric most easily damaged by an embed.
Give the iframe `loading="lazy"` when it sits below the fold, a `title` for accessibility, and `border: 0`. Set width and height to 100% of the ratio container rather than fixed pixels.
If your site sends a CSP header -- and a Next.js site with a security middleware often does -- the demo host must be allowed in `frame-src`. Miss it and the frame is blocked silently in production while working perfectly in local development, which is a genuinely miserable hour to debug.
Add the demo domain to `frame-src` explicitly rather than relaxing the policy, and check the browser console on the deployed site rather than trusting a local run.
An iframe embed needs no client-side JavaScript at all, so keep the wrapper a server component in the App Router. Marking it `use client` for no reason ships JavaScript you do not need.
The only case for a client component is the click-to-load pattern above, where you genuinely need state to swap the poster for the frame.
Click through it — the same kind of demo you can record of your own product.
Record your first interactive demo free.
Five demos on the free plan, forever. No credit card, no trial countdown, no sales call. Install the Chrome extension, click through your product once, and you have a shareable link in about ten minutes.
Start free →