Gathering detailed insights and metrics for @pisano/react-frame-component
Gathering detailed insights and metrics for @pisano/react-frame-component
Gathering detailed insights and metrics for @pisano/react-frame-component
Gathering detailed insights and metrics for @pisano/react-frame-component
Render your React app to an iFrame
npm install @pisano/react-frame-component
Typescript
Module System
Node Version
NPM Version
67
Supply Chain
94.4
Quality
74.9
Maintenance
100
Vulnerability
100
License
JavaScript (97.78%)
HTML (2.22%)
Total Downloads
5,601
Last Day
3
Last Week
14
Last Month
119
Last Year
932
MIT License
1,798 Stars
269 Commits
158 Forks
23 Watchers
9 Branches
44 Contributors
Updated on Jul 18, 2025
Latest Version
2.0.4
Package Id
@pisano/react-frame-component@2.0.4
Unpacked Size
195.26 kB
Size
53.10 kB
File Count
16
NPM Version
6.4.1
Node Version
8.12.0
Cumulative downloads
Total Downloads
Last Day
0%
3
Compared to previous day
Last Week
-36.4%
14
Compared to previous week
Last Month
98.3%
119
Compared to previous month
Last Year
-6.9%
932
Compared to previous year
3
36
This component allows you to encapsulate your entire React application or per component in an iFrame.
1npm install --save react-frame-component
1import Frame from 'react-frame-component';
Go check out the demo.
1const Header = ({ children }) => ( 2 <Frame> 3 <h1>{children}</h1> 4 </Frame> 5); 6 7ReactDOM.render(<Header>Hello</Header>, document.body);
Or you can wrap it at the render
call.
1ReactDOM.render( 2 <Frame> 3 <Header>Hello</Header> 4 </Frame>, 5 document.body 6);
head: PropTypes.node
The head
prop is a dom node that gets inserted before the children of the frame. Note that this is injected into the body of frame (see the blog post for why). This has the benefit of being able to update and works for stylesheets.
initialContent: PropTypes.string
Defaults to '<!DOCTYPE html><html><head></head><body><div></div></body></html>'
The initialContent
props is the initial html injected into frame. It is only injected once, but allows you to insert any html into the frame (e.g. a head tag, script tags, etc). Note that it does not update if you change the prop. Also at least one div is required in the body of the html, which we use to render the react dom into.
mountTarget: PropTypes.string
The mountTarget
props is a css selector (#target/.target) that specifies where in the initialContent
of the iframe, children will be mounted.
1<Frame 2 initialContent='<!DOCTYPE html><html><head></head><body><h1>i wont be changed</h1><div id="mountHere"></div></body></html>' 3 mountTarget='#mountHere' 4 > 5</Frame>
contentDidMount: PropTypes.func
contentDidUpdate: PropTypes.func
contentDidMount
and contentDidUpdate
are conceptually equivalent to
componentDidMount
and componentDidUpdate
, respecitvely. The reason these are
needed is because internally we call ReactDOM.render
which starts a new set of
lifecycle calls. This set of lifecycle calls are sometimes triggered after the
lifecycle of the parent component, so these callbacks provide a hook to know
when the frame contents are mounted and updated.
The iframe's window
and document
may be accessed via the React context values window
and document
respectively.
1const MyComponent = (props, context) => { 2 const { 3 document: iframeDocument, 4 window: iframeWindow 5 } = context; 6 7 return (<...rendered jsx.../>); 8}; 9 10MyComponent.contextTypes = { 11 window: PropTypes.any, 12 document: PropTypes.any 13};
I wrote a blog post about building this component.
Copyright 2014, Ryan Seddon. This content is released under the MIT license http://ryanseddon.mit-license.org
No vulnerabilities found.