Exit Button

In Hybrid Experience, your product owns the borrower journey until offer selection. After the borrower selects an offer, your back-end requests a Hosted URL and opens Hosted Experience for selected-offer execution.

The Hosted surface can show an Exit button after this handoff. This gives the borrower a clear way to leave the Aarthik Labs hosted step and return to your product.

Where It Applies

The Exit button applies after Hybrid has moved the borrower into Hosted Experience:

GET /api/v1/hybrid/personal-loan/borrowers/{borrowerProviderID}/journey/offers/{offerID}/hosted

The returned hosted_url is short-lived and should be opened immediately in the borrower browser, webview, or app shell.

For Hybrid handoff URLs, the Hosted session is created with the exit action enabled. Your app should be ready to handle the exit event before opening the returned hosted_url.

Handoff Flow

What The Borrower Sees

When the borrower is inside the Hosted handoff surface, Hosted shows an Exit button in the header.

When the borrower selects it, Hosted:

  1. clears the borrower session from the Hosted browser surface
  2. clears the applied Hosted theme from the page
  3. sends an aarthik-labs:exit event to the parent web page or mobile bridge
  4. attempts a best-effort browser close for Hybrid-to-Hosted sessions

The browser close is best-effort because browsers only allow window.close() in some contexts. Your app should still handle the exit event and close or hide the Hosted surface itself.

Web Handling

If your Hybrid UI opens Hosted in an iframe, modal, popup, or app-controlled browser surface, listen for the exit event.

1const handleAarthikLabsMessage = (event: MessageEvent) => {
2 if (event.data?.type !== "aarthik-labs:exit") return;
3
4 // Close the Hosted handoff surface and return to your Hybrid UI.
5 closeHostedExperience();
6 showHybridHomeOrDashboard();
7};
8
9window.addEventListener("message", handleAarthikLabsMessage);

The event payload looks like this:

1{
2 "type": "aarthik-labs:exit",
3 "version": 1,
4 "payload": {
5 "tenantID": "tenant-123",
6 "applicationID": "application-123",
7 "borrowerProviderID": "borrower-provider-123",
8 "timestamp": "2026-05-01T08:00:00.000Z"
9 }
10}

Use the event to close the Hosted surface. Do not use it as a loan-status signal. Loan progress should still come from the Hybrid APIs and lifecycle web-hooks.

Mobile App Handling

If your Hybrid journey runs inside a mobile app, register the mobile bridge before opening the Hosted URL.

Hosted can send the exit event through the supported mobile bridge surfaces, including:

  • ReactNativeWebView.postMessage
  • webkit.messageHandlers.AarthikLabs.postMessage
  • flutter_inappwebview.callHandler("onAarthikLabsExit", ...)
  • AarthikLabs.postMessage

When your app receives aarthik-labs:exit, close the Hosted webview or route the borrower back to your Hybrid app screen.

Read Mobile App Bridge for the full bridge contract.

For Hybrid integrations, we recommend:

  • register the web or mobile message handler before opening hosted_url
  • close or hide the Hosted surface after receiving aarthik-labs:exit
  • return the borrower to your product home, loan dashboard, or offer-summary screen
  • continue using lifecycle web-hooks and Hybrid APIs for actual journey status
  • request a fresh hosted_url if the borrower chooses to continue the selected offer later

Do not reuse an old hosted_url as a resume link. It contains short-lived session material and may expire.

Testing Checklist

Before launch, test:

  • the Hybrid offer-selection flow returns a hosted_url
  • the Hosted URL opens immediately after offer selection
  • the Exit button is visible after handoff
  • clicking Exit sends aarthik-labs:exit
  • your web page, webview, or app shell closes or hides Hosted
  • the borrower lands on the intended Hybrid app screen
  • reopening the selected offer requests a fresh hosted_url
  • mobile bridge handling works on real Android and iOS devices, if applicable