https://github.com/luoxuhai/react-native-tinykit
📱🔧 A lightweight React Native toolkit for iOS, providing essential native utilities
https://github.com/luoxuhai/react-native-tinykit
ios react-native
Last synced: 3 months ago
JSON representation
📱🔧 A lightweight React Native toolkit for iOS, providing essential native utilities
- Host: GitHub
- URL: https://github.com/luoxuhai/react-native-tinykit
- Owner: luoxuhai
- License: mit
- Created: 2025-12-31T06:03:16.000Z (6 months ago)
- Default Branch: master
- Last Pushed: 2026-01-18T01:47:13.000Z (6 months ago)
- Last Synced: 2026-01-18T13:53:21.328Z (6 months ago)
- Topics: ios, react-native
- Language: TypeScript
- Homepage:
- Size: 1.39 MB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# react-native-tinykit
[](https://www.npmjs.com/package/react-native-tinykit)
[](https://github.com/luoxuhai/react-native-tinykit/blob/master/LICENSE)
A lightweight React Native toolkit for iOS, providing essential native utilities (Zero dependencies).

## Features
- 🔄 **App Restart** - Programmatically restart your React Native application
- 🌡️ **Thermal State** - Get and monitor the device's thermal state
- ⭐ **App Review** - Request App Store review from within your app
- 🔅 **Keep Awake** - Prevent the screen from auto-locking
- ⚡ **Turbo Module** - Built with the new architecture for optimal performance
- 📦 **Lightweight** - Minimal footprint with zero dependencies
## Requirements
- React Native >= 0.76
- iOS only (for now)
## Installation
```sh
# Using npm
npm install react-native-tinykit
# Using yarn
yarn add react-native-tinykit
```
### iOS Setup
```sh
cd ios && pod install
```
## Usage
### Restart Application
Restart the React Native application programmatically:
```tsx
import { restart } from 'react-native-tinykit';
// Restart the app
restart();
```
#### Example Use Cases
- Force reload after language/locale change
- Reset app state after logout
- Apply configuration changes that require a restart
### Thermal State
Get the current thermal state and monitor for changes:
```tsx
import { getThermalState, onThermalStateChange } from 'react-native-tinykit';
// Get current thermal state
const state = getThermalState();
console.log('Current thermal state:', state);
// Listen for thermal state changes
const subscription = onThermalStateChange((state) => {
console.log('Thermal state changed:', state);
switch (state) {
case 'nominal':
// Normal operating conditions
break;
case 'fair':
// Slightly elevated thermal state
break;
case 'serious':
// High thermal state - consider reducing activity
break;
case 'critical':
// Critical thermal state - reduce activity immediately
break;
}
});
// Clean up the listener when done
subscription.remove();
```
#### Example Use Cases
- Reduce graphics quality or frame rate when device is overheating
- Pause background tasks during high thermal states
- Show warnings to users when thermal state is critical
### Keep Awake
Prevent the screen from auto-locking:
```tsx
import {
activate,
deactivate,
useKeepAwake,
KeepAwake,
} from 'react-native-tinykit';
// Imperative API
activate(); // Keep screen awake
deactivate(); // Allow screen to auto-lock
// Hook - keeps screen awake while the component is mounted
function VideoPlayer() {
useKeepAwake();
return ;
}
// Component - keeps screen awake while mounted
function App() {
return (
<>
>
);
}
```
#### Example Use Cases
- Keep the screen on during video playback
- Prevent auto-lock during navigation or long-running tasks
- Keep display active during presentations or reading
### App Review
Request an App Store review from your user:
```tsx
import { requestReview } from 'react-native-tinykit';
// Request review
await requestReview();
```
> **Note**: In development mode, the review dialog will always appear. In production (TestFlight/App Store), iOS limits the frequency of these prompts (max 3 times per year per user).
#### Example Use Cases
- Prompt for review after a user completes a significant action
- Ask for feedback after a certain number of app opens
## API Reference
### `restart()`
Triggers a reload of the React Native application.
```tsx
restart(): void
```
**Example:**
```tsx
import { restart } from 'react-native-tinykit';
const handleLogout = async () => {
await clearUserData();
restart(); // Restart app to reset state
};
```
### `getThermalState()`
Returns the current thermal state of the device.
```tsx
getThermalState(): ThermalState
```
**Returns:** `'nominal' | 'fair' | 'serious' | 'critical'`
| State | Description |
| ---------- | ----------------------------------------- |
| `nominal` | The thermal state is within normal limits |
| `fair` | The thermal state is slightly elevated |
| `serious` | The thermal state is high |
| `critical` | The thermal state is critically high |
**Example:**
```tsx
import { getThermalState } from 'react-native-tinykit';
const state = getThermalState();
if (state === 'critical') {
// Reduce app activity to help cool down the device
}
```
### `onThermalStateChange()`
Adds a listener for thermal state changes.
```tsx
onThermalStateChange(listener: (state: ThermalState) => void): { remove: () => void }
```
**Parameters:**
- `listener` - Callback function that receives the new thermal state
**Returns:** A subscription object with a `remove()` method to stop listening
**Example:**
```tsx
import { onThermalStateChange } from 'react-native-tinykit';
const subscription = onThermalStateChange((state) => {
console.log('Thermal state changed to:', state);
});
// Later, when you want to stop listening:
subscription.remove();
```
### `activate()`
Activates the keep-awake feature, preventing the screen from auto-locking.
```tsx
activate(): void
```
**Example:**
```tsx
import { activate } from 'react-native-tinykit';
activate();
```
### `deactivate()`
Deactivates the keep-awake feature, allowing the screen to auto-lock.
```tsx
deactivate(): void
```
**Example:**
```tsx
import { deactivate } from 'react-native-tinykit';
deactivate();
```
### `useKeepAwake()`
A hook that keeps the screen awake while the component is mounted. Automatically deactivates on unmount.
```tsx
useKeepAwake(): void
```
**Example:**
```tsx
import { useKeepAwake } from 'react-native-tinykit';
function VideoPlayer() {
useKeepAwake();
return ;
}
```
### ``
A component that keeps the screen awake while mounted. Renders nothing.
```tsx
```
**Example:**
```tsx
import { KeepAwake } from 'react-native-tinykit';
function App() {
const [isPlaying, setIsPlaying] = useState(false);
return (
<>
{isPlaying && }
setIsPlaying(true)} />
>
);
}
```
### `requestReview()`
Requests a review of the app.
```tsx
requestReview(): Promise
```
**Returns:** A Promise that resolves when the request is processed.
**Example:**
```tsx
import { requestReview } from 'react-native-tinykit';
const handleReview = async () => {
try {
await requestReview();
} catch (error) {
console.error('Failed to request review:', error);
}
};
```
## Apps Using This Library
- [Night Vision - LiDAR Camera](https://apps.apple.com/app/id1668629667)
- [Laser Measure - LiDAR Powered](https://apps.apple.com/app/id6466744678)
- [PhoneAway - Digital Detox](https://apps.apple.com/app/id6744548607)
- [Fatigue Alert - Stay Awake](https://apps.apple.com/app/id6479893638)
## Contributing
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
- [Development workflow](CONTRIBUTING.md#development-workflow)
- [Sending a pull request](CONTRIBUTING.md#sending-a-pull-request)
- [Code of conduct](CODE_OF_CONDUCT.md)
## License
MIT © [Darkce](https://github.com/luoxuhai)
---
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)