An open API service indexing awesome lists of open source software.

https://github.com/qnrjs42/react-native-nitro-restart

🔥 Insanely fast native C++, Swift or Kotlin modules with a statically compiled binding layer to JSI - restart, exit app
https://github.com/qnrjs42/react-native-nitro-restart

exit nitro nitro-modules react-native restart

Last synced: about 7 hours ago
JSON representation

🔥 Insanely fast native C++, Swift or Kotlin modules with a statically compiled binding layer to JSI - restart, exit app

Awesome Lists containing this project

README

          

# react-native-nitro-restart

Restart or exit your React Native app programmatically. Built with [Nitro Modules](https://github.com/mrousavy/nitro).

## Installation

```bash
npm install @qnrjs42/react-native-nitro-restart
# or
yarn add @qnrjs42/react-native-nitro-restart
# or
pnpm add @qnrjs42/react-native-nitro-restart

pnpm add -D react-native-nitro-modules
```

Then run pod install for iOS:

```bash
cd ios && pod install
```

## Usage

```typescript
import { restartApp, exitApp } from '@qnrjs42/react-native-nitro-restart';

// Restart the app
restartApp();

// Exit the app
exitApp();
```

That's it.

## API

### `restartApp()`

Restarts your React Native app.

- iOS: Uses React Native's built-in reload mechanism
- Android: Relaunches the main activity with a fresh task

### `exitApp()`

Exits the application.

- iOS: Suspends and exits after 0.5s
- Android: Kills the process cleanly

## Examples

### Restart after language change

```typescript
import { restartApp } from '@qnrjs42/react-native-nitro-restart';
import AsyncStorage from '@react-native-async-storage/async-storage';

const changeLanguage = async (lang: string): Promise => {
await AsyncStorage.setItem('language', lang);
restartApp();
};
```

### Exit on logout

```typescript
import { exitApp } from '@qnrjs42/react-native-nitro-restart';

const logout = async (): Promise => {
await clearUserData();
exitApp();
};
```

## Requirements

- React Native >= 0.70
- iOS >= 13.0
- Android >= 21
- react-native-nitro-modules (peer dependency)

## Why Nitro?

Nitro provides direct native calls without the React Native bridge, making this library fast and type-safe with zero overhead.

## License

MIT