How to Embed a Power Apps Code App in an Iframe (Step-by-Step Guide)
How to Embed a Power Apps Code App in an Iframe
Looking to surface your Power Apps code app inside a model-driven app web resource, a custom website, or any third-party service that supports iframes? You're in the right place. Embedding a code app via iframe unlocks powerful integration possibilities — letting you deliver rich, interactive experiences without forcing users to navigate away from their existing workflows.
In this step-by-step guide, we'll walk you through exactly how to embed a code app in an iframe, covering everything from prerequisites to configuration best practices. Whether you're a developer or a Power Platform enthusiast, this guide has you covered.
What Is a Power Apps Code App?
A code app in Power Apps is a developer-focused application type that gives you full control over your app's behavior using code — as opposed to the low-code canvas approach. Code apps are ideal when you need custom UI components, complex logic, or seamless integration with external systems.
For more on what Power Apps and the Power Platform can do for your business, visit our Power Platform Development page.
Prerequisites
Before embedding your code app in an iframe, make sure you have the following in place:
- A published Power Apps code app with a valid app URL
- Appropriate permissions to configure the host environment (e.g., model-driven app, website)
- An understanding of your host platform's iframe support and Content Security Policy (CSP) settings
- Access to your Power Platform environment with the necessary admin rights
Step 1: Retrieve Your Code App URL
To embed your code app, you first need its unique URL. Here's how to find it:
- Sign in to Power Apps.
- Navigate to Apps in the left-hand navigation.
- Locate your code app and click the three-dot menu (...) next to it.
- Select Details and copy the Web link URL.
Keep this URL handy — you'll need it in the next step.
Step 2: Configure iframe Permissions
Because code apps enforce security policies, you must explicitly allow them to be embedded in an iframe. This involves configuring the Content Security Policy (CSP) settings within your Power Platform environment.
Allow iframe Embedding in Power Platform Admin Center
- Go to the Power Platform Admin Center.
- Select your Environment.
- Navigate to Settings > Privacy + Security.
- Under Content Security Policy, add your host domain to the allowed list of frame ancestors.
- Save your changes.
⚠️ Important: Failing to configure CSP settings correctly will result in the iframe being blocked by the browser. Always test in your target environment after making changes.
Step 3: Add the Iframe to Your Host
Once your app URL is ready and permissions are configured, you can embed the code app using a standard HTML <iframe> tag. Here's a basic example:
<iframe
src="https://apps.powerapps.com/play/<your-app-id>?tenantId=<your-tenant-id>"
width="100%"
height="600px"
frameborder="0"
allow="microphone; camera; geolocation"
allowfullscreen
></iframe>
Key Iframe Attributes Explained
- src — The full URL of your Power Apps code app
- width / height — Set dimensions to fit your layout (use percentages for responsiveness)
- frameborder — Set to
0for a clean, borderless embed - allow — Grant specific browser permissions your app may need (e.g., microphone, camera)
- allowfullscreen — Enables fullscreen mode if supported by your app
Step 4: Embed in a Model-Driven App Web Resource
If your target host is a model-driven app, you can embed the code app as an HTML web resource:
- In your model-driven app, go to Settings > Customizations > Customize the System.
- Navigate to Web Resources and create a new HTML web resource.
- Paste your iframe code into the HTML file.
- Save and publish the web resource.
- Add the web resource to the desired form or page in your model-driven app.
- Save and publish the app.
Need help setting up or customising your model-driven app environment? Explore our Dynamics 365 Implementation Services for expert support.
Step 5: Test the Embedded App
After embedding, always thoroughly test your iframe integration:
- ✅ Verify the app loads correctly inside the iframe
- ✅ Check that authentication works as expected (users shouldn't need to sign in twice)
- ✅ Test on multiple browsers (Chrome, Edge, Firefox, Safari)
- ✅ Validate mobile responsiveness if applicable
- ✅ Confirm that any app features requiring device permissions (camera, microphone) function correctly
- ✅ Check browser console for any CSP or mixed-content errors
Common Issues and Troubleshooting
The iframe Shows a Blank Page
This is most commonly caused by a Content Security Policy misconfiguration. Double-check that your host domain has been added to the frame ancestors list in the Power Platform Admin Center.
Users Are Prompted to Sign In Again
Ensure that your host and the Power Apps environment share the same Azure AD tenant, and that cross-origin cookies are permitted. Consider using seamless single sign-on (SSO) configurations where possible.
App Doesn't Resize Properly
Use percentage-based width values and set a fixed or viewport-relative height. You can also use JavaScript's postMessage API to dynamically resize the iframe based on the app's content height.
Best Practices for Iframe Embedding
- Always use HTTPS for both the host and the app URL
- Restrict
allowattributes to only what your app genuinely needs - Implement robust error handling in case the iframe fails to load
- Regularly review CSP settings as your environment evolves
- Use Power Automate to trigger workflows from within your embedded app for even richer integration
Supercharge Your Power Platform Solutions
Embedding code apps in iframes is just one of the many powerful techniques available within the Microsoft Power Platform ecosystem. Whether you're building custom portals, integrating apps into existing business tools, or creating seamless user experiences, the Power Platform gives you the flexibility to do it all.
At CRMONCE, our team of certified Power Platform specialists can help you design, build, and deploy solutions that truly fit your business needs — from architecture planning to full implementation.
- 🔧 Power Platform Development — Custom apps, flows, and portals
- ⚙️ Dynamics 365 Implementation — End-to-end D365 deployments
- 🤖 Power Automate Solutions — Intelligent process automation
- 🎓 Professional Training — Upskill your team
- 💬 Consulting Services — Strategic guidance from experts
Ready to Build Something Powerful?
Whether you need help embedding Power Apps into your existing systems or want to explore what the Power Platform can do for your organisation, our experts are ready to help.