Skip to main content

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.

Open in sdk-example
  • openURL — open an external URL.

External references