Exit Button
Hosted Experience can show an Exit button in the borrower header. Use this when Hosted is opened inside your website, mobile app, or partner demo surface and you want the borrower to return to your app instead of staying inside the Aarthik Labs journey shell.
The button is optional for direct Hosted integrations. Enable it only on the Hosted URL instances where your app is ready to handle the exit event.
When To Use It
Use the Exit button when:
- Hosted is embedded in your web app through an
iframe - Hosted is opened inside your mobile app or webview
- your product has its own home screen, dashboard, or loan marketplace that the borrower should return to
- you want a clear borrower-controlled way to leave the Hosted journey
You do not need it when Hosted opens as a standalone browser journey and the borrower can use normal browser navigation.
Enable The Button
First, create the Hosted URL from your back-end with POST /api/lab/sessions.
Then, before opening the returned URL in your front-end, add:
as a query parameter on the embedURL.
Example:
If you are building the URL manually for a test, keep the query parameter before the # fragment:
Do not remove or log the URL fragment. It contains short-lived session material.
What The Borrower Sees
When show_exit=true is present, Hosted shows an Exit button in the header.
When the borrower selects it, Hosted:
- clears the borrower session from the Hosted browser surface
- clears the applied Hosted theme from the page
- sends an
aarthik-labs:exitevent to the parent web page or mobile bridge
Your app decides what happens next. Common actions are closing the iframe, hiding the Hosted screen, navigating to your app home page, or reopening your product dashboard.
Web iframe Handling
If Hosted runs inside your web page, listen for message events from the Hosted frame.
The event payload looks like this:
Use borrowerProviderID and timestamp for support logs or analytics. Do not treat this event as a loan outcome. It only means the borrower pressed Exit.
Mobile App Handling
If Hosted runs inside a mobile app, register the mobile bridge before loading the Hosted URL.
Hosted can send the exit event through the supported mobile bridge surfaces, including:
ReactNativeWebView.postMessagewebkit.messageHandlers.AarthikLabs.postMessageflutter_inappwebview.callHandler("onAarthikLabsExit", ...)AarthikLabs.postMessage
When your app receives aarthik-labs:exit, close the Hosted webview or route the borrower back to your app-owned screen.
Read Mobile App Bridge for the full bridge contract.
Recommended Behavior
For a clean borrower experience:
- show your own loading state while Hosted is closing
- close or hide the Hosted container after receiving
aarthik-labs:exit - return the borrower to a safe app-owned screen
- create a fresh Hosted URL if the borrower starts again later
- log the event type, timestamp, and borrower reference for support
Avoid trying to reuse the same embedURL after exit. If the borrower wants to continue later, call your back-end again and create a fresh URL for the same borrowerProviderID.
Testing Checklist
Before launch, test:
- Hosted URL opens with
show_exit=true - the
Exitbutton is visible in the Hosted header - clicking Exit sends
aarthik-labs:exit - your web page, webview, or app shell closes or hides Hosted
- the borrower lands on the intended app-owned screen
- starting again creates a fresh Hosted URL
- mobile bridge handling works on real Android and iOS devices, if applicable