closeView
Closes the current mini-app view and returns to the host (Toss) app. Call this when the user has completed a task or explicitly decides to leave the mini-app.
Signature
import { closeView } from '@apps-in-toss/web-framework';
declare function closeView(): Promise<void>;
Parameters
None.
Returns
Promise<void>— resolves once the close request is delivered.- In the devtools mock,
window.history.back()is called instead.
Permission
No permission required.
Examples
Minimal
import { closeView } from '@apps-in-toss/web-framework';
await closeView();
Realistic — closing after a completed payment
import { closeView } from '@apps-in-toss/web-framework';
import { useState } from 'react';
export function PaymentSuccess() {
const [closing, setClosing] = useState(false);
async function handleClose() {
setClosing(true);
await closeView();
}
return (
<div>
<p>Payment complete!</p>
<button type="button" onClick={handleClose} disabled={closing}>
{closing ? 'Closing…' : 'Close'}
</button>
</div>
);
}
Try it live
Open the Navigation page in sdk-example and run the closeView card.
Related APIs
openURL— open an external URL.
Related guides
- Guides — Mini-app navigation flow patterns — mini-app entry/exit, opening external URLs, and screen-context (orientation, awake, secure) patterns.
External references
@apps-in-toss/web-framework— SDK package. The actual exports are re-exported from@apps-in-toss/web-bridge.