React Iframe Component

1.8.5 · active · verified Tue Apr 21

react-iframe is a React component designed to simplify the integration of `<iframe>` elements into React applications. It acts as a convenient, TypeScript-supported wrapper around the native HTML `<iframe>` tag, abstracting common setup and attribute handling. The current stable version is 1.8.5. While it does not follow a strict release cadence, the project appears actively maintained with recent updates and comprehensive TypeScript support, making it well-suited for modern React development. Its key differentiator is providing a prop-driven interface for `iframe` attributes, including graceful handling of HTML5 deprecated attributes (like `frameBorder` and `allowFullScreen`), and offering explicit, convenient props for `sandbox` and `allow` attributes, which are crucial for security and feature control in contemporary web development and can be more cumbersome to manage directly with a plain `<iframe>` element.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates basic integration of the `Iframe` component, including essential layout props, explicit `frameBorder` setting, and examples of crucial `allow` and `sandbox` attributes for modern iframe security and feature control.

import React from 'react';
import Iframe from 'react-iframe';

function MyPage() {
  return (
    <div>
      <h1>My Embedded Content</h1>
      <Iframe 
        url="https://www.sdrive.app/embed/1ptBQD"
        width="640px"
        height="320px"
        id="my-sdrive-iframe"
        className="my-iframe-class"
        display="block"
        position="relative"
        frameBorder={0}
        allow="fullscreen; camera; microphone; geolocation"
        sandbox="allow-scripts allow-same-origin allow-forms allow-popups"
        styles={{ border: '1px solid #ccc', borderRadius: '8px' }}
      />
      <p>Content below the iframe.</p>
    </div>
  );
}

export default MyPage;

view raw JSON →