{"id":16382536,"url":"https://github.com/demchenkoalex/react-native-module-template","last_synced_at":"2025-10-04T13:10:53.770Z","repository":{"id":35742735,"uuid":"219142288","full_name":"demchenkoalex/react-native-module-template","owner":"demchenkoalex","description":"A starter for the React Native library written in TypeScript, with linked example project and optional native code in Swift and Kotlin.","archived":false,"fork":false,"pushed_at":"2023-09-18T23:21:26.000Z","size":2931,"stargazers_count":217,"open_issues_count":24,"forks_count":36,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-06-29T11:02:27.380Z","etag":null,"topics":["android","boilerplate","ios","kotlin","react-native","swift","template","typescript","xcode"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/demchenkoalex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-02T11:09:23.000Z","updated_at":"2025-05-07T12:57:33.000Z","dependencies_parsed_at":"2024-10-24T01:18:12.481Z","dependency_job_id":"baa1155d-f9a0-4993-b40e-e0cd5d0eff67","html_url":"https://github.com/demchenkoalex/react-native-module-template","commit_stats":{"total_commits":80,"total_committers":2,"mean_commits":40.0,"dds":"0.025000000000000022","last_synced_commit":"b44f785965ecb364cbfbdd710b5989336d11a86c"},"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/demchenkoalex/react-native-module-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demchenkoalex%2Freact-native-module-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demchenkoalex%2Freact-native-module-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demchenkoalex%2Freact-native-module-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demchenkoalex%2Freact-native-module-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/demchenkoalex","download_url":"https://codeload.github.com/demchenkoalex/react-native-module-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demchenkoalex%2Freact-native-module-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278316346,"owners_count":25966971,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","boilerplate","ios","kotlin","react-native","swift","template","typescript","xcode"],"created_at":"2024-10-11T04:05:41.610Z","updated_at":"2025-10-04T13:10:53.722Z","avatar_url":"https://github.com/demchenkoalex.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Native Module Template\n\nA starter for the React Native library written in TypeScript, with linked example project and optional native code written in Swift and Kotlin. This project aims to support the latest React Native versions and keep best practices in mind.\n\nAre you looking for the project template? Check [react-native-better-template](https://github.com/demchenkoalex/react-native-better-template).\n\n## Alternatives\n\n[react-native-builder-bob](https://github.com/callstack/react-native-builder-bob)\n\n[create-react-native-module](https://github.com/brodybits/create-react-native-module)\n\n### Why this template?\n\nFirst of all, it has TypeScript set up and ready. Also, if you will use a native code, this template uses Swift and Kotlin, which is much better than Objective-C and Java.\n\nThe example project is linked in a way so that you can work on your library and see the results of your work immediately. If you use native code you can see linked libraries in the example project opened in Xcode or Android Studio and can modify the code directly from there, just remember to rebuild the example to see the changes. When you change TypeScript code you need to compile it first (using `yarn` command, it has `prepare` hook set up) since with npm you are supplying `lib` folder with JavaScript and type definitions, but there is an [option](#how-to-see-my-changes-immediately-in-the-example) to point example to the `src` folder instead, so that when you modify your library you see changes immediately in the example thanks to [Fast Refresh](https://facebook.github.io/react-native/docs/fast-refresh).\n\n## Usage\n\nClone this repo, rename the `react-native-module-template` folder to your library name, navigate to that folder and run\n\n```\nnode rename.js\n```\n\nor if you want to **remove native code**\n\n```\nnode rename.js js-only\n```\n\nThis will invoke rename script, which removes all references to the template and makes some cleanup.\n\n⚠️⚠️⚠️ This script is not made to be bulletproof, some assumptions are made:\n\n- The script will ask for different information (such as library name, author name, author email etc.) and there might be instructions in the parenthesis, please follow them or something will likely **fail**.\n- Use `kebab-case` for the library name, _preferably_ with `react-native` prefix (e.g. `react-native-blue-button`, blue-button, button).\n- Use `PascalCase` for the library short name (in case you will have native code, with `js-only` argument script will not ask for this), it is used in native projects (RNModuleTemplate.xcodeproj, RNModuleTemplatePackage.kt etc.). If you prefixed your library name with `react-native` use prefix `RN` for the short name (e.g. `RNBlueButton`, BlueButton, Button).\n- Library homepage is used only in `package.json`, if you are not sure, you can press enter to skip this step and modify this field later. Library git url is used only in `.podspec` file, same as above (note that this file will be removed if you pass `js-only` argument).\n- Please don't use any special characters in author name since it is a part of Android package name, (e.g. `com.alexdemchenko.reactnativemoduletemplate`) and used in Kotlin and other files. Android package name is generated from author name (with removed spaces and lowercased) and library name (with removed dashes).\n\nDon't forget to remove the rename script, do `yarn` to install dependencies in root and example folders, and, if you kept native code, do `pod install` in `example/ios`.\n\nIf you didn't use `js-only` you are good to go. If you did, you need to unlink native code from the example\n\n### iOS\n\nOpen Xcode, in the project navigator find `Libraries` folder, reveal contents using the small arrow and hit `DELETE` on `RNModuleTemplate.xcodeproj`. Alternatively, open `example/ios/example.xcodeproj/project.pbxproj`, search for the `Template` (there should be a number of `libRNModuleTemplate.a` and `RNModuleTemplate.xcodeproj` files) and remove all references to them. Please remove whole lines if it among files with other names or whole sections if it is the only item. Groups, like `Library` or `Products`, must stay, just remove the template from appropriate children field.\n\n### Android\n\nIn `example/android/settings.gradle` remove\n\n```gradle\ninclude ':react-native-module-template'\nproject(':react-native-module-template').projectDir = new File(rootProject.projectDir, '../../android')\n```\n\nIn `example/android/app/build.gradle` remove\n\n```gradle\nimplementation project(':react-native-module-template')\n```\n\nIn `example/android/app/src/main/java/com/example/MainApplication.kt` remove\n\n```kotlin\nimport com.alexdemchenko.reactnativemoduletemplate.RNModuleTemplatePackage\n\npackages.add(RNModuleTemplatePackage())\n```\n\n## How example project is linked\n\nThe native part is manually linked (you can see changes for Android right above), for iOS check [official docs](https://facebook.github.io/react-native/docs/linking-libraries-ios#manual-linking), but **Header Search Paths** are pointing to the `ios` folder, `$(SRCROOT)/../../ios`, not node_modules.\n\nJavaScript part is using Metro Bundler configuration, see [this article](https://callstack.com/blog/adding-an-example-app-to-your-react-native-library/) for more details and final configuration [here](example/metro.config.js).\n\nIn the example's [tsconfig.json](example/tsconfig.json) custom path is specified, so you can import your code the same way end user will do.\n\n```json\n\"paths\": {\n  \"react-native-module-template\": [\"../src\"]\n},\n```\n\n### How to see my changes immediately in the example\n\nIn the library's `package.json` change\n\n```json\n\"main\": \"lib/index.js\",\n```\n\nto\n\n```json\n\"main\": \"src/index.tsx\", // or `index.ts` if you don't have JSX there\n```\n\nrestart the bundler if you have it running\n\n```\nyarn start\n```\n\n⚠️⚠️⚠️ Don't forget to change this back before making a release, since with npm you supply `lib` folder, not `src`. Let me know if there is a way to do this automatically.\n\n## Release\n\nCreate an npm account [here](https://www.npmjs.com/signup) if you don't have one. Then do\n\n```\nnpm login\n```\n\nand\n\n```\nnpm publish\n```\n\nℹ️ If you want to see what files will be included in your package before release run `npm pack`\n\nℹ️ If you have native code in your library most of the time you will need `.kt`, `.h`/`.m`, `.swift` files, `project.pbxproj`, `AndroidManifest.xml` and `build.gradle` aside from TypeScript code and default stuff, so keep an eye on what you are publishing, some configuration/build folders or files might sneak in. Most of them (if not all) are ignored in [package.json](package.json).\n\n## FAQ\n\n### VSCode ESLint plugin does not lint example project\n\nBy default, ESLint is configured separately for the library's source code and the example. It uses two `.eslintignore` files, the first one for the library, among others it ignores `/example` folder, and the second one for the example project. Since `/example` folder is ignored in one of these files, the plugin does not lint anything in it, see this [issue](https://github.com/microsoft/vscode-eslint/issues/111). To fix that, go to the VSCode settings and set\n\n```json\n\"eslint.workingDirectories\": [\n\t\"./example\"\n]\n```\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdemchenkoalex%2Freact-native-module-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdemchenkoalex%2Freact-native-module-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdemchenkoalex%2Freact-native-module-template/lists"}