New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

use-parent-data

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-parent-data

transfer data to iframe child from parent react hook

latest
Source
npmnpm
Version
1.1.5
Version published
Maintainers
1
Created
Source

parent side

import React, { useRef } from 'react'
import { useParentDataParent } from 'use-parent-data'

export const IframePage = () => {
  const iframe = useRef<HTMLIFrameElement>(null)

  const targetOriginChild = 'http://localhost:3000'
  type TData = { userId: string }

  useParentDataParent<TData>({
    data: { userId: '1' },
    iframeRef: iframe,
    targetOrigin: targetOriginChild, // default '*'
  })

  return (
    <iframe
      ref={iframe}
      src="http://localhost:3000/child-page"
      width="100%"
      height={window.innerHeight}
    />
  )
}

child side

import React from 'react'
import { useParentDataChild } from 'use-parent-data'

export const ChildPage = () => {
  const targetOriginParent = 'http://localhost:3001' // default '*'

  type TParentData = {
    userId: string
  }

  const { parentData } = useParentDataChild<TParentData>(targetOriginParent)

  useEffect(() => {
    console.log(parentData)
  }, [parentData])

  return <div>{`userId: ${parentData?.userId}`}</div>
}

FAQs

Package last updated on 30 Mar 2026

Did you know?

Socket

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.

Install

Related posts