Skip to content

Minshak/bun-native

Repository files navigation

bun-native

🌀 bun-native

⚡ Use Bun as a blazing-fast package manager with React Native projects.
This tool patches Metro and handles Bun-specific quirks so you can enjoy faster installs and cleaner dependencies.


🚀 Features

  • ✅ Metro bundler compatibility with Bun's symlinked dependencies
  • ✅ Generates a node_modules_mirror/ for clean Metro resolution
  • ✅ Patches metro.config.js automatically
  • ✅ Wrapper commands for run-ios, run-android, and start
  • ✅ Postinstall hook support for seamless integration

📦 Installation

Install globally via npm:

npm install -g bun-native

Make sure you have Bun installed

curl -fsSL https://bun.sh/install | bash

🧪 Usage

🆕 Initialize a New Project (React Native CLI)

bun-native init

Creates a new React Native project and installs everything using Bun.

📦 Customize the Project Name

You can pass a name to create your project:

bun-native init MyApp

🧪 Choose a Specific React Native Version

Use the --version flag to target a specific RN version:

bun-native init MyApp --version 0.78.1

✅ Migrate an Existing React Native Project

cd your-react-native-app

# Clean up old installs
rm -rf node_modules package-lock.json yarn.lock

# Install dependencies with Bun
bun install

# Patch Metro + Generate node_modules
bun-native postinstall

# Run the app
bun-native start
bun-native run-ios
bun-native run-android

🧠 How It Works

•	Uses Bun’s .bun/install/cache to generate a flat node_modules_mirror/ layout
•	Modifies metro.config.js to resolve modules from the mirror
•	Wraps npx react-native commands for convenience

🛠 Available Commands

Command Description
init Initialize a new React Native project using Bun
patch-metro Patch Metro to work with Bun
postinstall Run postinstall to patch Metro and create mirror layout
run-android Run react-native run-android
run-ios Run react-native run-ios
start Run react-native start
bundle Run react-native bundle

⚠️ Known Limitations

•	Not yet compatible with all complex native modules — but works well for most.
•	Metro doesn’t fully support Bun’s symlink layout — hence the node_modules_mirror.

🤝 Contributing

Pull requests are welcome! Ideas, templates, and bug reports are also appreciated.

📜 License

MIT © 2025 Kologo B Josias Yannick

Buy me a coffee

If my you find my work usefull and want to support me, kindly buy me a coffee here

Buy Me A Coffee

About

Use Bun as a package manager with React Native

Resources

License

Stars

Watchers

Forks

Packages

No packages published