amplify pull command to share the same Amplify backend across multiple frontends (e.g, a React and Android app). Users have an option to pull the entire backend definition (infrastructure templates and metadata) or only the metadata (e.g. the
amplifyconfiguration.json file) required to connect to the backend. If you’re building a mobile and web app in separate repositories, the recommended workflow is to keep the backend definition (the amplify folder) in only one of the repositories and pull the metadata (the
amplifyconfiguration.json file) in the second repository to connect to the same backend.
This workflow outlines the steps required to share a backend across two (or more) frontends. This example scenario is for a team building an Android and React app.
- Initialize a backend for your React app. This will create an Amplify project and backend environment that is accessible in the Amplify Console (by running
1$ cd my-react-app2 $ amplify init3 ? Enter a name for the project: ecommerce4 ? Choose the type of app that you're building: react5 $ amplify add api6 $ amplify push
Make your frontend changes and commit the code to Git. Your Git repository now stores the
amplifyfolder which contains the definition of your infrastructure.
Reference the backend from your Android app using the
amplify pullcommand. Choose 'No' when asked if you want to modify or add new categories to your backend. This will put the
amplifyconfigurationto your src folder only. Choosing 'Yes' will work, however your backend definition will now be stored in two separate repositories leading to unintended consequences with multiple sources of truth.
1cd my-android-app2 amplify pull3 ? Which app are you working on?4 > ecommerce5 mysecretproject6 ? Choose the type of app that you're building: #android7 ? Do you plan on modifying this backend?: #n8 Successfully pulled backend environment dev from the cloud.9 Run 'amplify pull' to sync upstream changes.