Context
I am implementing embedded Quick Sight analytics in my Next.js 14 application using the App Router. I have multiple dashboards, each containing several sheets. My goal is to provide a seamless user experience where each page in my app displays only one specific sheet, without the default Quick Sight navigation bar, only the sheet content should be visible.
I am using the “Create Embed URL for Registered User” approach to generate the embedded Quick Sight URLs.
Problem
On navigating between pages, the embedded Quick Sight URL becomes invalid. It seems that since Next.js unmounts the iframe during navigation, the embedded session is lost, and the URL cannot be reused. This forces me to fetch a new embed URL every time the user navigates to a different page, which negatively impacts the user experience.
Questions :
- Is this expected behavior?
Given the way Next.js and React handle component unmounting, is this behavior something inherent to the framework’s lifecycle? - Does the Quick Sight SDK provide a way to persist the session across page navigations?
I explored different solutions but couldn’t find a straightforward way to retain the embed URL across navigations. - Potential Solutions:
3.1 One approach I am considering is using a React portal to keep the iframe mounted globally and only update its content.
3.2 Another option is rendering all dashboards within the main layout and showing/hiding them instead of remounting on every navigation.
3.3 Are there any best practices or recommended patterns for handling embedded Quick Sight in Next.js?
I want to ensure that this is an expected limitation of how Next.js (App Router) and React handle component lifecycles rather than an issue in my implementation. Any insights or alternative solutions would be greatly appreciated!