Skip to content

How to deploy a production React Native Amplify front-end to App Store with amplify_outputs.json

2

I continue to struggle with some basic questions about Amplify, the documentation is good for development but almost non-existant for Production.

I have a React Native app build with Expo which uses Amplify Cognito and DynamoDB backend services. I have the backend configured and building in AWS and that is working fine.

Now I need to build my front end and deploy on the Apple App store, but amplify_outputs is clearly excluded from the repo in .gitinore and I can't see how the front-end App can connect to the backend resources without it. There is no reference to anything in amlify_outputs in the 'ios' folder generated as part of the build.

My question is therefore, how does one go about shipping amplify_outputs (or backend configuration) with the App?

asked a year ago468 views

2 Answers
0

@Jaffer Mustafa

How did you go about this? I am going through the same questions in my head

answered 9 months ago

  • Hi - I came up with a solution but not a very good one. I copied amplify_outputs to the generated iOS folder, then opened the solution in the iOS folder in Xcode and deployed as you normally would from there. Manual, but it worked

-1
    When deploying a React Native app with AWS Amplify to the App Store, you need to properly handle the connection between your frontend and backend. While amplify_outputs.json is excluded from git repositories by default for security reasons, there are proper approaches to handle this for production deployments.

    For a production React Native app using Amplify, you should:

    1. **Generate a production configuration file**: Instead of directly using amplify_outputs.json in your production build, you should create environment-specific configurations. For Amplify Gen 2, you would download the amplify_outputs.json from your deployed backend resources and place it in your app's repository root during the build process.

    2. **Automate the configuration**: You can set up your CI/CD pipeline to automatically download and include the latest amplify_outputs.json during the build process. This ensures your production app always connects to the correct backend resources.

    3. **Configure Amplify in your app**: In your React Native app's initialization code (typically in App.js or similar), you need to import and configure Amplify with your backend configuration:
    ```
    import Amplify from 'aws-amplify';
    import aws_exports from './amplify_outputs.json'; // or your config path
    Amplify.configure(aws_exports);
    ```

    4. **Build for production**: When building your app for App Store submission, ensure the build process includes the proper configuration file. For Expo builds, you can use EAS Build or the traditional expo build process, making sure the amplify_outputs.json is included in the build.

    5. **Create a signed build**: Generate a production-ready, signed build of your app that includes all necessary configurations.

    6. **Test thoroughly**: Before submission to the App Store, test your production build to ensure it correctly connects to your Amplify backend services.

    This approach ensures your production app can securely connect to your Amplify backend while maintaining proper security practices by not committing sensitive configuration to your source code repository.
  

Sources
Fullstack TypeScript: Reintroducing AWS Amplify | Front-End Web & Mobile
Get Started - AWS Mobile Hub
Working with AWS AppSync Events: Serverless WebSockets for Pub/Sub | Front-End Web & Mobile
How to launch the app after completing the Frontend and Backend using amplify | AWS re:Post

answered a year ago

  • This might be the worst answer I have ever seen; it doesn't even look like an AI, but rather a template.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.