
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
simple-iframe-resizer
Advanced tools
simple-iframe-resizer helps you to auto resize cross-domain iframe dimensions based on the content size
simple-iframe-resizer helps you to auto resize cross-domain iframe dimensions based on the content size
It works as react hooks, and is only compatible with React>=16.8.0
# npm
npm install simple-iframe-resizer --save
# yarn
yarn add simple-iframe-resizer
# pnpm
pnpm add simple-iframe-resizer
Two hooks are used in iframe and host respectively, useResizeChild and useResizeParent. For convenience, we treat iframe as child and host as parent.
useResizeChild: used within iframe context.useResizeParent: used within host context that containing a iframe elementUse it in both parent and child side. simple-iframe-resizer will use this event name to communicate between parent and child through postMessage. Make sure the event name is unique to avoid interference.
// Example event name
const RESIZE_EVENT_NAME = "__simple_iframe_resizer_demo_9f9292a4"
import { useResizeChild } from "simple-iframe-resizer"
function ChildApp() {
const [domRef] = useResizeChild(RESIZE_EVENT_NAME)
return <div ref={domRef}>Hello World</div>
}
import { useResizeParent } from "simple-iframe-resizer"
function ParentApp() {
const iframeRef = useRef<HTMLIFrameElement>(null)
const iframeWindowRef = useRef<Window | undefined>()
useEffect(() => {
iframeWindowRef.current = iframeRef.current?.contentWindow || undefined
}, [])
const [rect] = useResizeParent(RESIZE_EVENT_NAME, iframeWindowRef)
return (
<iframe
ref={iframeRef}
src="https://www.example.com"
height={rect.height || "100%"}
width={rect.width || "100%"}
/>
)
}
onUnmount event and reset the iframe heightconst [domRef, rpcClient] = useResizeChild(RESIZE_EVENT_NAME)
useEffect(() => {
return () => rpcClient.onUnmount()
}, [])
const [rect, childRpcClient] = useResizeParent(
RESIZE_EVENT_NAME,
iframeWindowRef,
)
useEffect(() => {
childRpcClient.getSize().then((rect) => {
console.log(rect)
})
}, [])
interface ParentFunctions {
onResize: (rect: DOMRectReadOnly) => void
onUnmount: () => void
}
interface ChildFunctions {
getSize: () => DOMRectReadOnly | undefined
}
declare const useResizeChild: <T extends Element>(
id: string,
) => [React.RefObject<T>, ParentRpcClient | undefined]
declare const useResizeParent: (
id: string,
windowRef: React.MutableRefObject<Window | undefined>,
) => [DOMRectReadOnly | undefined, ChildRpcClient | undefined]
FAQs
simple-iframe-resizer helps you to auto resize cross-domain iframe dimensions based on the content size
We found that simple-iframe-resizer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.