An optimized React Native library boilerplate equipped with valuable tools, simplifying library development and ensuring high-quality code.
MIT License
This repository is an optimized React Native library boilerplate, designed to boost your library development process.🧑💻🔧 It's tailored for both bare React Native applications and Expo-created ones. This boilerplate is equipped with valuable tools, simplifying library development and ensuring high-quality code.
jest
setup is also available with example testsNode 18 or greater is required. Development for iOS needs a Mac and Xcode.
To create a fresh project, just run:
npx rn-lib-temp init <projectName>
Before starting development, go to the directory where you created the template project and install all necessary dependencies with yarn
:
yarn
For iOS only: Install required Pods for the bare React Native example app:
yarn example:bare pod
For more details about the npx rn-lib-temp
command use the following command:
npx rn-lib-temp help
To use the GitHub Actions bundled with this boilerplate, you'll need to provide 2 secrets (refer to this page for more about secrets):
GH_TOKEN
- a GitHub token with repo
permissions (check docs for more on GitHub access tokens).NPM_TOKEN
- an npm token employed by semantic-release for automatic library deployment (see docs for info on npm access tokens).Alternatively, remove workflows from the .github
directory if you prefer not to use GitHub Actions.
he repository uses the most common monorepo structure where the example
directory contains the example app and the packages
directory contains sources of the library itself, as well as, documentation and other packages (if necessary).
By default, the resulting library will include files specified under the files
key in the packages/<your-library-name>/package.json
:
src
directory - where you write all library source code,dist
directory - generated by react-native-builder-bob during the build process,LICENSE
- you should include your LICENSE
file because it's not provided by default,CHANGELOG.md
- a file containing all version history with included changes, automatically generated by the semantic-release library,README.md
- readme file from the repository root directorydependencies
field in the packages/<your-library-name>/package.json
react-native-reanimated
),peerDependencies
field in the packages/<your-library-name>/package.json
,dependencies
of the example app (added to the example/app/package.json
)All dependencies should be installed with yarn
in order to ensure that yarn workspaces work properly.
The example app is located in the example
directory. Inside, you'll find three subdirectories:
app
- Where the example app source code is located.bare
- Sources necessary to run the bare react native app.expo
- Sources of the expo-managed app.If you don't need to include expo or a bare React Native app example, you can just remove the corresponding directory.
For launching the bare React Native example app:
yarn example:bare start|android|ios|pod
For the Expo React Native app:
yarn example:expo start|android|ios
start
- starts metro clientandroid
- starts example app on the Android emulator/device,ios
- starts example app on the iOS simulator/device,pod
- installs Pods required by example app native iOS dependencies.The release.yaml
workflow included in the project contains the auto deployment logic. By default, the deployment will be caused on the workflow dispatch action (manually from the GitHub Actions page). You can change this behavior by modifying the workflow triggers.