npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

rn-app-exit

v1.0.2

Published

Exit or background your React Native app — supports New Architecture (TurboModules) and Old Architecture with Kotlin/Swift native implementations.

Readme

rn-app-exit

Exit or background your React Native app — with full New Architecture (TurboModules) support, written in Kotlin and Objective-C++.

npm version npm downloads license platform


Why this package?

Most apps eventually need one of two things:

  • Hard exit — a logout button, a kiosk reset, a session wipe that kills the process
  • Background — a "minimize" button, a back-to-home UX without killing the process

The original react-native-exit-app only does the first, is written in Java/Objective-C, has no TurboModule support, and hasn't been maintained since 2021. This package does both, properly.


Features

| | react-native-exit-app | rn-app-exit | |---|---|---| | Exit app | ✅ | ✅ | | Send to background | ❌ | ✅ | | Unified API | ❌ | ✅ | | Capability flags | ❌ | ✅ | | New Architecture (TurboModules) | ❌ | ✅ | | Old Architecture | ✅ | ✅ | | Language | Java / ObjC | Kotlin / ObjC++ | | Active maintenance | ❌ (2021) | ✅ | | Min React Native | 0.60 | 0.68 |


Installation

npm install rn-app-exit

iOS

cd ios && pod install

Android

No additional steps — auto-linked via React Native's autolinking.


Usage

import AppExit from 'rn-app-exit';

Hard exit (kill the process)

AppExit.exitApp();

Terminates the app process immediately. The app is removed from recents on Android. On iOS, use this only for non-App-Store builds (kiosks, enterprise, dev tooling) — Apple's HIG discourages exit() in consumer App Store apps.

Send to background (keep process alive)

AppExit.sendToBackground();

Moves the app to the background without terminating. The process stays alive in memory — the user can resume from the app switcher exactly where they left off.

  • Android: calls moveTaskToBack(true) — native OS feature, fully reliable
  • iOS: suspends via UIApplication suspend selector — works across all current iOS versions

Unified API

// Hard exit (default)
AppExit.exit();

// Background instead of kill
AppExit.exit({ background: true });

The exit() method is the recommended API for most use cases. Pass { background: true } to move to background instead of killing.

Check capability at runtime

if (AppExit.isBackgroundSupported) {
  // Android: always true
  // iOS: false — backgrounding is OS-controlled
  AppExit.sendToBackground();
} else {
  AppExit.sendToBackground(); // still works on iOS via best-effort suspend
}

API Reference

AppExit.exit(options?)

| Parameter | Type | Default | Description | |---|---|---|---| | options.background | boolean | false | When true, sends to background instead of killing |

AppExit.exitApp()

Kills the process.

| Platform | Implementation | |---|---| | Android | activity.finish() + Process.killProcess(myPid()) | | iOS | exit(0) |

iOS warning: Apple's App Store review guidelines discourage programmatic exit. Prefer sendToBackground() in consumer iOS apps.

AppExit.sendToBackground()

Moves the app to the background without terminating the process.

| Platform | Implementation | |---|---| | Android | activity.moveTaskToBack(true) | | iOS | UIApplication suspend selector |

AppExit.isBackgroundSupported

booleantrue on Android, false on iOS.

On Android, moveTaskToBack is a first-class OS feature. On iOS, backgrounding is managed by the OS and there is no public API — the package uses a best-effort approach that works on current iOS versions but is not a documented public API.


TypeScript

Full TypeScript support is included. The exported types are:

type AppExitOptions = {
  background?: boolean;
};

Platform notes

Android

All three methods work as expected on Android API 21+. sendToBackground() behaves exactly like pressing the Home button — the task moves to the back stack and the process continues running.

iOS

Apple does not provide a public API for programmatic backgrounding or exit in App Store apps. This package provides:

  • exitApp() via exit(0) — works, but risks App Store rejection for consumer apps. Safe for enterprise/kiosk/dev builds.
  • sendToBackground() via UIApplication suspend — has been stable across iOS versions and does not trigger App Store rejection the way exit() can.

For App Store consumer apps, the recommended pattern is:

// Show a "goodbye" screen or navigate home, then suspend
AppExit.sendToBackground();

New Architecture

This package supports React Native's New Architecture (TurboModules) out of the box. The JavaScript spec in src/NativeAppExit.ts is used by React Native's codegen to generate native bindings automatically.

No additional configuration is needed. The package detects the active architecture at build time and uses the appropriate native implementation.


Common use cases

Logout button that wipes state and exits:

async function handleLogout() {
  await clearUserSession();
  AppExit.exitApp();
}

Kiosk reset button:

function KioskResetButton() {
  return (
    <Pressable onPress={() => AppExit.exit()}>
      <Text>Reset Kiosk</Text>
    </Pressable>
  );
}

Minimize button (Android UX pattern):

function MinimizeButton() {
  return (
    <Pressable onPress={() => AppExit.sendToBackground()}>
      <Text>Go to Home</Text>
    </Pressable>
  );
}

Hardware back button on Android to background instead of exit:

import { BackHandler } from 'react-native';

useEffect(() => {
  const sub = BackHandler.addEventListener('hardwareBackPress', () => {
    AppExit.sendToBackground();
    return true; // prevent default back behavior
  });
  return () => sub.remove();
}, []);

License

MIT © 2025 pixelcube


Contributing

Issues and PRs welcome at github.com/yashpyraj/rn-app-exit.