Iframe
1 min read
An app that makes it possible to render external iframes on a store website.

Configuration - standard Iframe
- Add
vtex.iframeto the theme's dependencies in themanifest.jsonfile.
_10"dependencies": {_10 "vtex.iframe": "0.x"_10}
- Add the
iframeinterface to any custom page (iframes are not allowed outside custom pages).
_14{_14 "store.custom#about-us": {_14 "blocks": [_14 "flex-layout.row#about-us",_14 "iframe"_14 ]_14 },_14_14 "iframe": {_14 "props": {_14 "src": ""_14 }_14 }_14}
| Prop name | Type | Description | Default value |
|---|---|---|---|
src | String | Source address the iframe should render | null |
width | Number | Width attribute of the iframe | null |
height | Number | Height attribute of the iframe | null |
allow | String | allow attribute of the iframe | null |
Configuration - dynamic Iframe
- Add
vtex.iframeto the theme's dependencies in themanifest.jsonfile.
_10"dependencies": {_10 "vtex.iframe": "0.x"_10}
- Add the
iframe.dynamic-srcblock and its properties to theblocks.jsonfile.
_16{_16 "store.custom#locationPage":{_16 "children":[_16 "iframe.dynamic-src"_16 ]_16 },_16 "iframe.dynamic-src":{_16 "props": {_16 "dynamicSrc": "https://www.test.com/exampleStaticPathName/{dynamicParam1}/{dynamicParam2}/exampleStaticPageName",_16 "width": "1920",_16 "height": "1000",_16 "title": "exampleStaticPageName iframe wrapper for {account}",_16 "allow": "geolocation"_16 }_16 }_16}
- Register your new page in
routes.jsonwith the appropriate parameters passed into the page URL.
_10{_10 "store.custom#locationPage":{_10 "path": "/:param1/:param2/pagename"_10 }_10}
| Prop name | Type | Description | Default value |
|---|---|---|---|
dynamicSrc | String | iframe src with dynamic parameters from page URL enclosed in '{}' | null |
width | Number | Width attribute of the iframe | null |
height | Number | Height attribute of the iframe | null |
title | String | title attribute of the iframe | null |
allow | String | allow attribute of the iframe | null |
Customization
There is a .container handle that wraps the iframe. It's also possible to use blockClass.