๐คน React Native Starter - Powered by cli-rn, React Native Navigation, Expo Modules, RNN Screens, RN UI lib, MMKV, Mobx, Reanimated 2, Dark Mode, Splash Screen, Localization, Notifications, Permissions, and much more.
This starter is a collection of libraries and approaches needed for fast start and productive maintainance of React Native App.
RNN Starter is a part of starters.dev collection.
npx cli-rn new App -t rnn
As
cli-rn
usesreact-native-rename
script for renaming under the hood, please refer to Rename section to apply necessary changes to Android part.
If you have any troubles running the app with yarn ios
or yarn android
, open XCode or Android Studio and run the project from there.
npx degit kanzitelli/rnn-starter app
cd app && yarn && yarn ios:pods
Open XCode or Android Studio to run the project (recommended) or do
yarn ios
yarn android
If you need to rename the app, do the following (based on react-native-rename):
yarn rename "NewApp" -b com.yourcompany.newapp
yarn ios:pods
โ ๏ธ Troubleshooting on Android. You can see that after running rename
script, it doesn't change package name and imports for files under newarchitecture
folder.
Open all .java
files under android/app/src/main/java/your/bundle/newarchitecture/
folder.
Open MainApplication.java
.
Find all packages and imports which contain com.rnnstarter
and change them to yours.
nav
- a service where some of navigation configuration takes place in (such as default options).translate
- a service that brings an easy integration of localization for an app by using i18n-js and expo-localization.api
- a service where API-related methods are located.onStart
- a service where you can write your own logic when app is launched. For example, you can increment number of appLaunches
there.Starting from v16.0.0
, we have added a Splash Screen that works great on pair with React Native Navigation and can be hidden at any moment in your app! Thanks to @FawadMahmood!
Current approach relies on
LaunchImage
on iOS that is marked as deprecated by Apple. However, people still use it and that's the only way to make it work with React Native Navigation.
At some point of the app development, you'll probably want to replace existing splash screen (with starters.dev icon). Below, you can find some tutorials/advices on how to replace the splash screen images.
If you already have some images ready for Splash Screen, you can just drag and drop them instead of existing Images/LaunchImage
in XCode.
If you'd like to generate new images, then follow the steps below.
We are going to use rn-toolbox to achieve that. You can use any other tool or website.
Follow the requirements and installation steps for rn-toolbox.
Prepare splashscreen.psd
with the design of your splash screen.
Run yarn splash:gen
.
Now, splash screens for iOS and Android must be generated and you should manually add them to the following folders.
Note for Android: discard any changes of
styles.xml
if it was accidentally overwritten by the script.
Note for iOS: key
UILaunchStoryboardName
must be removed fromInfo.plist
file andLaunchImage
value must be set for "Asset Catalog Launch Image" in Build Settings.
Splash Screen hides loading state of the app bundle when launching the app in debug mode.
This starter is using RN UI lib as a design system, UI toolset and a source of ready-to-go components.
DesignSystem
- a class where all settings for an app's design system is taking place. You can customize colors, schemes, typegraphy, spacings, etc. Located at src/utils/designSystem.tsx
.
https://user-images.githubusercontent.com/4402166/197052859-d7eef80a-a923-4a9b-86df-b9dbc32a075b.mov
All setup for your screens takes place in one file src/screens/index.ts
:
import {generateRNNScreens} from 'rnn-screens';
import {Main} from './main';
import {Settings} from './settings';
export const screens = generateRNNScreens(
{
Main: {
component: Main,
options: {
topBar: {
...withTitle('Main'),
...withRightButtons('inc', 'dec'),
},
},
},
Settings: {
component: Settings,
options: {
topBar: {
...withTitle('Settings'),
},
},
},
// ...
},
[withGestureHandler, withSS, withAppearance],
);
import {screens} from '.';
const SomeScreen = ({componentId}) => {
return (
<View>
<Button
label="Open screen"
onPress={() => {
// IDE will autocomplete with registered screens
screens.push(componentId, 'AnotherScreen');
}}
/>
</View>
);
};
// single screen app
const App = () => Root(Screen(screens.get('Main')));
// tab based app
const TabsApp = () =>
Root(
BottomTabs([
Screen(screens.get('Main')),
Screen(screens.get('Playground')),
Screen(screens.get('Settings')),
]),
);
You can define modes in utils/designSystem.tsx
.
So you have one structure within the project. You can find them in corresponding folders. Just copy&paste it and make the necessary changes.
There are still some things I would like to add to the starter:
Feel free to open an issue for suggestions.
hermes.framework
is not found/loaded in XCode with React Native 0.70. Check this and this comments for potential solution.patches/react-native+0.70.0.patch
.yarn rename
script. Check Rename section for possible solution.Originally bootstrapped from starters-dev/rnn-with-expo.
...do we need yet another starter/boilerplate? Well, I work with React Native for more than 4 years and during the time I started having my own project structure which was a good fit for almost all of the delivered apps. Also, I have come up with some custom useful services/methods which simplify usage of React Native Navigation and other libraries. Check out Advantages section.
This project is MIT licensed