Vue Friendly Iframe is a Vue.js component designed to simplify the creation and management of dynamic, asynchronous iframes, based on Aaron Peters' iframe loading techniques. The current stable version is 0.20.0, with releases occurring somewhat irregularly but indicating active maintenance, often driven by feature additions or bug fixes. Its primary differentiator is providing a controlled, event-driven mechanism for loading external content within an iframe, making it easier to interact with the iframe's lifecycle and attributes. It specifically supports Vue 2.x projects and integrates as a Vue plugin, offering props for `src`, `sandbox`, `allow`, `allowfullscreen`, and custom events for load states, aiming to provide a safer and more performant iframe experience compared to native iframe usage. It abstracts away some of the complexities of handling iframe content and security attributes.
npm install vue-friendly-iframeVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to install `vue-friendly-iframe` as a Vue plugin, set its source, and handle `load` and `message` events, including essential `sandbox` and `allow` attributes for security and functionality.
Ensure your Vue application calls `Vue.use(VueFriendlyIframe)` once during initialization, typically in your main.js file.
Remove the `scrolling` attribute from your `<vue-friendly-iframe>` component. Use CSS properties like `overflow: auto;` or `overflow: scroll;` on the iframe or its containing element if you need to control scrolling behavior.
Use this package exclusively with Vue 2.x projects. For Vue 3, consider looking for a Vue 3 compatible iframe component or building a custom solution.
Ensure the content loaded in the iframe has appropriate CORS headers if you need to access its DOM or listen to events from it. For sandboxed iframes, explicitly include `allow-same-origin` in the `sandbox` attribute if necessary.
Ensure you have `import VueFriendlyIframe from 'vue-friendly-iframe';` and `Vue.use(VueFriendlyIframe);` in your main Vue entry file (e.g., main.js) before your Vue instance is created.
This is a server-side restriction. You must either use a different `src` that permits embedding or request the owner of the content to modify their server's `X-Frame-Options` or CSP. You cannot bypass this client-side.