gitwtfhub

wtf is iframe-pane?

antfu/iframe-pane — explained in plain English

Analysis updated 2026-05-18

46TypeScriptAudience · developerComplexity · 2/5Setup · easy

TL;DR

A headless JavaScript library that keeps iframes parked in an overlay so they never lose state when moved, hidden, or re-rendered in a web app.

Mindmap

mindmap
  root((iframe-pane))
    What it does
      Parks iframes off-tree
      Preserves iframe state
      Syncs position and size
    Tech stack
      TypeScript
      JavaScript
    Use cases
      Persist tabs across switches
      Keep devtools iframe alive
      Lock pointer events on drag
    Audience
      Frontend developers
      Framework authors

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Why would anyone build with this?

REASON 1

Keep an embedded iframe's state intact while switching tabs or panels in an app.

REASON 2

Persist a live preview iframe, like a devtools panel, across component re-renders.

REASON 3

Temporarily block iframes from stealing pointer events during a drag or resize.

What's in the stack?

TypeScriptJavaScript

How it stacks up

antfu/iframe-paneamirappleidfd-stack/netmeliieasychen/quick-avatar
Stars464646
LanguageTypeScriptTypeScriptTypeScript
Setup difficultyeasymoderateeasy
Complexity2/53/52/5
Audiencedeveloperops devopsdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you spin it up?

Difficulty · easy Time to first run · 5min

Single package install, framework-agnostic with zero dependencies.

Wtf does this do

iframe-pane is a small JavaScript and TypeScript library for keeping iframes alive and in their original state as you move them around a web page. Normally, when a piece of code removes an iframe from the page or moves it to a different spot in the layout, the iframe loses everything it was doing: its scroll position, whatever page it had navigated to, any typed input, all of it starts over. This is a common problem in apps built with frameworks like Vue or React, where switching tabs or re rendering part of the page can silently reset an embedded iframe. The library solves this by keeping every iframe parked inside one dedicated overlay area that is never re rendered by your framework. Your own components only render an empty placeholder element, and the library positions the real iframe on top of that placeholder, following it as it moves or resizes. Hiding an iframe does not remove it from the page, it just makes it invisible and unclickable while it keeps running in the background, so bringing it back later restores it exactly as it was left. It has no dependencies and works with any framework, or with no framework at all. It offers several extra conveniences: automatic resizing to match the size of its target element, a way to temporarily block iframes from capturing mouse and touch events during dragging or resizing elsewhere on the page, and an optional limit on how many iframes can be kept alive at once, automatically closing the least recently used ones when that limit is reached. It can also manage plain elements like a div in the same persistent way, not just iframes, and it is safe to use in server rendered applications since it only touches the actual page once the browser runs it. Installation is a single package manager command, and the basic usage is to create a manager, ask it to create or reuse a named pane pointed at a URL, then mount that pane onto any element on the page whenever you want it shown.

Yoink these prompts

Prompt 1
Add iframe-pane to my Vue or React app to stop an embedded iframe resetting on tab switch.
Prompt 2
Set up iframe-pane with a maxPanes limit so old iframes get disposed automatically.
Prompt 3
Use iframe-pane's lockPointerEvents while the user resizes a split panel.
Prompt 4
Manage a persistent div-based dock element with iframe-pane instead of an iframe.

Frequently asked questions

wtf is iframe-pane?

A headless JavaScript library that keeps iframes parked in an overlay so they never lose state when moved, hidden, or re-rendered in a web app.

What language is iframe-pane written in?

Mainly TypeScript. The stack also includes TypeScript, JavaScript.

How hard is iframe-pane to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is iframe-pane for?

Mainly developer.

View the repo → Decode another repo

This repo across BitVibe Labs

Don't trust strangers blindly. Verify against the repo.