Allows Mini Apps to close themselves programmatically. Useful for completion flows, cancellation actions, or after successful operations.
Returns
Function that closes the Mini App frame and returns the user to the host application.
Usage Patterns
Completion Flows
Close automatically after successful operations:components/CompletionFlow.tsx
Navigation Replacement
Use close instead of navigation for simple flows:components/NavigationReplacement.tsx
Error Recovery
Provide escape routes for error states:components/ErrorScreen.tsx
Best Practices
User Experience
- Confirm important actions: Ask before closing if user has unsaved work
- Provide feedback: Show completion states before auto-closing
- Quick escape: Always provide a way to close, especially in error states
Technical Considerations
- Save state: Persist important data before closing
- Clean up: Cancel ongoing requests or timers
- Analytics: Track close events for UX insights
components/HandleClose.tsx
useClose
provides a clean exit for Mini Apps. Use it thoughtfully to create polished user experiences that feel native to the host application flow.