Giftie
SDK reference

Opening and closing

Understand the Giftie modal lifecycle and upload close protection.

Open from a user action

Call open() from a click or another explicit user action. The loader creates a full-screen dialog, inserts an iframe, and grants the iframe camera and microphone permissions for the browser to request from the shopper.

openButton.addEventListener('click', () => {
  giftie.open({ mode: 'video' })
})

Calling open() again while the widget is open has no effect.

Close paths

The current release closes when:

  • your page calls giftie.close();
  • the shopper uses the widget's close control;
  • the shopper presses Escape while the widget is open; or
  • a recording is saved successfully.

The loader restores focus to the element that was active before opening when it can. onClose runs after an accepted close has started but before the loader resets isOpen(), iframe, upload, and focus state. The loader does not await a promise returned by onClose; it continues the reset immediately. A synchronous throw prevents that reset and can leave lifecycle state inconsistent even though the 300 ms visual removal has already been scheduled.

Upload protection

Giftie blocks the first close attempt while an upload is in progress. A second close attempt forces the widget closed, which can abandon the upload.

Do not repeatedly call close() from timers or route watchers. Let the shopper confirm a forced close through a deliberate second action.

Configuration timing

updateConfig() and per-open configuration are shallow merges. Updating the instance while it is open does not rebuild or message the existing iframe; the new values take effect on the next accepted open.

isLoaded() only means the iframe load event fired. It does not mean the shopper granted permissions or completed a recording.

Copyright © 2026