PageSourceSearch

https://reactnative.dev/assets/js/7d242582.91dbf8e6.js

js reactnative.dev collected 2026-09-24 07:17:23 UTC 6,742 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkreact_native_website=self.webpackChunkreact_native_website||[]).push([["1466"],{24665(e,t,o){o.r(t),o.d(t,{metadata:()=>r,default:()=>u,frontMatter:()=>a,contentTitle:()=>s,toc:()=>l,assets:()=>d});var r=JSON.parse('{"id":"how-to-build-from-source","title":"How to Build from Source","description":"You will need to build React Native from source if you want to work on a new feature/bug fix, try out the latest features which are not released yet, or maintain your own fork with patches that cannot be merged to the core.","source":"@site/contributing/how-to-build-from-source.md","sourceDirName":".","slug":"/how-to-build-from-source","permalink":"/contributing/how-to-build-from-source","draft":false,"unlisted":false,"editUrl":"[{\\"label\\":\\"Edit this page\\",\\"href\\":\\"https://github.com/facebook/react-native-website/edit/main/docs/how-to-build-from-source.md\\"}]","tags":[],"version":"current","lastUpdatedAt":1757662806000,"frontMatter":{"title":"How to Build from Source"},"sidebar":"contributing","previous":{"title":"How to Contribute Code","permalink":"/contributing/how-to-contribute-code"},"next":{"title":"How to Run and Write Tests","permalink":"/contributing/how-to-run-and-write-tests"}}'),i=o(62540),n=o(43023);let a={title:"How to Build from Source"},s,d={},l=[{value:"Android",id:"android",level:2},{value:"Prerequisites",id:"prerequisites",level:3},{value:"Point your project to a nightly",id:"point-your-project-to-a-nightly",level:3},{value:"Update your project to build from source",id:"update-your-project-to-build-from-source",level:3},{value:"Additional notes",id:"additional-notes",level:3},{value:"Rationale",id:"rationale",level:2}];function c(e){let t={a:"a",code:"code",h2:"h2",h3:"h3",p:"p",pre:"pre",strong:"strong",...(0,n.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(t.p,{children:"You will need to build React Native from source if you want to work on a new feature/bug fix, try out the latest features which are not released yet, or maintain your own fork with patches that cannot be merged to the core."}),"\n",(0,i.jsx)(t.h2,{id:"android",children:"Android"}),"\n",(0,i.jsx)(t.h3,{id:"prerequisites",children:"Prerequisites"}),"\n",(0,i.jsxs)(t.p,{children:["To build from source, you need to have the Android SDK installed. If you followed the ",(0,i.jsx)(t.a,{href:"/docs/environment-setup",children:"Setting up the development environment"})," guide, you should already be set up."]}),"\n",(0,i.jsxs)(t.p,{children:["There is no need to install other tools like specific version of NDK or CMake as the Android SDK will ",(0,i.jsx)(t.strong,{children:"automatically download"})," whatever is needed for the build from source."]}),"\n",(0,i.jsx)(t.h3,{id:"point-your-project-to-a-nightly",children:"Point your project to a nightly"}),"\n",(0,i.jsx)(t.p,{children:"To use the latest fixes and features of React Native, you can update your project to use a nightly version of React Native with:"}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{children:"yarn add react-native@nightly\n"})}),"\n",(0,i.jsx)(t.p,{children:"This will update your project to use a nightly version of React Native that gets released every night with the latest changes."}),"\n",(0,i.jsx)(t.h3,{id:"update-your-project-to-build-from-source",children:"Update your project to build from source"}),"\n",(0,i.jsxs)(t.p,{children:["Both with stable releases and nightlies, you will be consuming ",(0,i.jsx)(t.strong,{children:"precompiled"})," artifacts. If instead you want to switch to building from source, so you can test your changes to the framework directly, you will have to edit the ",(0,i.jsx)(t.code,{children:"android/settings.gradle"})," file as follows:"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-diff",metastring:'title="Diff"',children:'  // ...\n  include \':app\'\n  includeBuild(\'../node_modules/@react-native/gradle-plugin\')\n\n+ includeBuild(\'../node_modules/react-native\') {\n+     dependencySubstitution {\n+         substitute(module("com.facebook.react:react-android")).using(project(":packages:react-native:ReactAndroid"))\n+         substitute(module("com.facebook.react:react-native")).using(project(":packages:react-native:ReactAndroid"))\n+         substitute(module("com.facebook.react:hermes-android")).using(project(":packages:react-native:ReactAndroid:hermes-engine"))\n+         substitute(module("com.facebook.react:hermes-engine")).using(project(":packages:react-native:ReactAndroid:hermes-engine"))\n+     }\n+ }\n'})}),"\n",(0,i.jsx)(t.h3,{id:"additional-notes",children:"Additional notes"}),"\n",(0,i.jsx)(t.p,{children:"Building from source can take a long time, especially for the first build, as it needs to download ~200 MB of artifacts and compile the native code."}),"\n",(0,i.jsxs)(t.p,{children:["Every time you update the ",(0,i.jsx)(t.code,{children:"react-native"})," version from your repo, the build directory may get deleted, and all the files are re-downloaded.\nTo avoid this, you might want to change your build directory path by editing the ",(0,i.jsx)(t.code,{children:"~/.gradle/init.gradle"})," file:"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-groovy",metastring:'title="Groovy"',children:'gradle.projectsLoaded {\n    rootProject.allprojects {\n        buildDir = "/path/to/build/directory/${rootProject.name}/${project.name}"\n    }\n}\n'})}),"\n",(0,i.jsx)(t.h2,{id:"rationale",children:"Rationale"}),"\n",(0,i.jsxs)(t.p,{children:["The recommended approach to working with React Native is to always update to the latest version. The support we provide for older versions is ",(0,i.jsx)(t.a,{href:"https://github.com/reactwg/react-native-releases/#releases-support-policy",children:"described 
1in our support policy"}),"."]}),"\n",(0,i.jsx)(t.p,{children:"The build from source approach should be used to end-to-end test a fix before submitting a pull request to React Native, and we're not encouraging its usages in the long run. Especially forking React Native or switching your setup to always use a build from source, will result in projects that are harder to update and generally a worse developer experience."})]})}function u(e={}){let{wrapper:t}={...(0,n.R)(),...e.components};return t?(0,i.jsx)(t,{...e,children:(0,i.jsx)(c,{...e})}):c(e)}},43023(e,t,o){o.d(t,{R:()=>a,x:()=>s});var r=o(63696);let i={},n=r.createContext(i);function a(e){let t=r.useContext(n);return r.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function s(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:a(e.components),r.createElement(n.Provider,{value:t},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.